This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SCENARIO: A prospective Customer registers her account | |
| When a Customer registers as [Fiona Gallagher] with [[email protected]] | |
| Then her account should show the data she supplied: | |
| GivenName: Fiona | |
| FamilyName: Gallagher | |
| EmailAddress: [email protected] | |
| IsEmailAddressConfirmed: false | |
| SCENARIO: A prospective Customer can't register because her email address is already used | |
| Given a Customer registered as [Fiona Gallagher] with [[email protected]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package shared | |
| import "github.com/cockroachdb/errors" | |
| var ( | |
| ErrInputIsInvalid = errors.New("input is invalid") | |
| ErrNotFound = errors.New("not found") | |
| ErrDuplicate = errors.New("duplicate") | |
| ErrDomainConstraintsViolation = errors.New("domain constraints violation") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package value | |
| import ( | |
| "github.com/AntonStoeckl/go-iddd/service/shared" | |
| "github.com/cockroachdb/errors" | |
| "github.com/google/uuid" | |
| ) | |
| type CustomerID struct { | |
| value string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package domain | |
| import ( | |
| "github.com/AntonStoeckl/go-iddd/service/customeraccounts/application/domain/customer/value" | |
| "github.com/AntonStoeckl/go-iddd/service/shared/es" | |
| ) | |
| type CustomerRegistered struct { | |
| customerID value.CustomerID | |
| emailAddress value.EmailAddress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package es | |
| type DomainEvent interface { | |
| Meta() EventMeta | |
| IsFailureEvent() bool | |
| FailureReason() error | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package es | |
| import ( | |
| "reflect" | |
| "strings" | |
| "time" | |
| ) | |
| const ( | |
| metaTimestampFormat = time.RFC3339Nano |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package domain | |
| import ( | |
| "github.com/AntonStoeckl/go-iddd/service/customeraccounts/application/domain/customer/value" | |
| ) | |
| type RegisterCustomer struct { | |
| customerID value.CustomerID | |
| emailAddress value.EmailAddress | |
| confirmationHash value.ConfirmationHash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package customer | |
| import ( | |
| "github.com/AntonStoeckl/go-iddd/service/customeraccounts/application/domain" | |
| "github.com/AntonStoeckl/go-iddd/service/customeraccounts/application/domain/customer/value" | |
| "github.com/AntonStoeckl/go-iddd/service/shared/es" | |
| ) | |
| type currentState struct { | |
| id value.CustomerID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package customer | |
| import ( | |
| "github.com/AntonStoeckl/go-iddd/service/customeraccounts/application/domain" | |
| ) | |
| func Register(with domain.RegisterCustomer) domain.CustomerRegistered { | |
| event := domain.BuildCustomerRegistered( | |
| with.CustomerID(), | |
| with.EmailAddress(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package customer | |
| import ( | |
| "github.com/AntonStoeckl/go-iddd/service/customeraccounts/application/domain" | |
| "github.com/AntonStoeckl/go-iddd/service/shared/es" | |
| "github.com/cockroachdb/errors" | |
| ) | |
| func ConfirmEmailAddress(eventStream es.EventStream, command domain.ConfirmCustomerEmailAddress) (es.RecordedEvents, error) { | |
| customer := buildCurrentStateFrom(eventStream) |
OlderNewer