Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
Signed-off-by: Arsene <[email protected]>
  • Loading branch information
Tochemey authored Mar 20, 2024
1 parent 6f714ff commit e4c19c4
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,29 +158,29 @@ func (a *AccountBehavior) InitialState() *samplepb.Account {
}

// HandleCommand handles every command that is sent to the persistent behavior
func (a *AccountBehavior) HandleCommand(_ context.Context, command Command, _ *samplepb.Account) (events []Event, err error) {
switch cmd := command.(type) {
case *samplepb.CreateAccount:
// TODO in production grid app validate the command using the prior state
return []Event{
&samplepb.AccountCreated{
AccountId: cmd.GetAccountId(),
AccountBalance: cmd.GetAccountBalance(),
},
}, nil

case *samplepb.CreditAccount:
// TODO in production grid app validate the command using the prior state
return []Event{
&samplepb.AccountCredited{
AccountId: cmd.GetAccountId(),
AccountBalance: cmd.GetBalance(),
},
}, nil

default:
return nil, errors.New("unhandled command")
}
func (a *AccountBehavior) HandleCommand(_ context.Context, command ego.Command, _ *samplepb.Account) (events []ego.Event, err error) {
switch cmd := command.(type) {
case *samplepb.CreateAccount:
// TODO in production grid app validate the command using the prior state
return []ego.Event{
&samplepb.AccountCreated{
AccountId: cmd.GetAccountId(),
AccountBalance: cmd.GetAccountBalance(),
},
}, nil

case *samplepb.CreditAccount:
// TODO in production grid app validate the command using the prior state
return []ego.Event{
&samplepb.AccountCredited{
AccountId: cmd.GetAccountId(),
AccountBalance: cmd.GetBalance(),
},
}, nil

default:
return nil, errors.New("unhandled command")
}
}

// HandleEvent handles every event emitted
Expand Down

0 comments on commit e4c19c4

Please sign in to comment.