Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type AccountAggregate struct {
- cmdHandlers map[string]CommandHandler
- evHandlers map[string]EventHandler
- }
- func NewAccountAggregate() Aggregate {
- a := &AccountAggregate{}
- a.cmdHandlers = map[string]CommandHandler{
- "CreateAccount": a.createAccount,
- }
- a.evHandlers = map[string]EventHandler{
- "AccountCreated": a.onAccountCreated,
- }
- return a
- }
- func (a *AccountAggregate) createAccount(cmd Command) error {
- ev := Event{"AccountCreated", cmd.Payload}
- a.Causes(ev)
- return nil
- }
- func (a *AccountAggregate) onAccountCreated(ev Event) {
- // persisting of data
- }
- func (a *AccountAggregate) Load(events []Event) { … }
- func (a *AccountAggregate) Process(cmd Command) error { … }
- func (a *AccountAggregate) Causes(ev Event) { … }
Add Comment
Please, Sign In to add comment