Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
AntonStoeckl / scenarios.txt
Last active May 4, 2020 13:44
Acceptance Test Scenarios for my iDDD with Go blog article series at https://medium.com/@TonyBologni
SCENARIO: A prospective Customer registers her account
When a Customer registers as [Fiona Gallagher] with [fiona@gallagher.net]
Then her account should show the data she supplied:
GivenName: Fiona
FamilyName: Gallagher
EmailAddress: fiona@gallagher.net
IsEmailAddressConfirmed: false
SCENARIO: A prospective Customer can't register because her email address is already used
Given a Customer registered as [Fiona Gallagher] with [fiona@gallagher.net]
@AntonStoeckl
AntonStoeckl / Errors.go
Last active May 4, 2020 13:49
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
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")
@AntonStoeckl
AntonStoeckl / CustomerID.go
Created May 4, 2020 13:51
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
package value
import (
"github.com/AntonStoeckl/go-iddd/service/shared"
"github.com/cockroachdb/errors"
"github.com/google/uuid"
)
type CustomerID struct {
value string
@AntonStoeckl
AntonStoeckl / CustomerRegistered.go
Created May 4, 2020 13:53
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
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
@AntonStoeckl
AntonStoeckl / DomainEvent.go
Created May 4, 2020 13:57
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
package es
type DomainEvent interface {
Meta() EventMeta
IsFailureEvent() bool
FailureReason() error
}
@AntonStoeckl
AntonStoeckl / EventMeta.go
Created May 4, 2020 13:58
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
package es
import (
"reflect"
"strings"
"time"
)
const (
metaTimestampFormat = time.RFC3339Nano
@AntonStoeckl
AntonStoeckl / RegisterCustomer.go
Created May 4, 2020 14:23
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
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
@AntonStoeckl
AntonStoeckl / currentState.go
Created May 4, 2020 14:26
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
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
@AntonStoeckl
AntonStoeckl / Register.go
Created May 4, 2020 14:28
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
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(),
@AntonStoeckl
AntonStoeckl / ConfirmEmailAddress.go
Created May 4, 2020 14:30
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
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)