You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: behavior.go
+4-4
Original file line number
Diff line number
Diff line change
@@ -35,13 +35,13 @@ type Event proto.Message
35
35
typeState proto.Message
36
36
37
37
// EntityBehavior defines an event sourced behavior when modeling a CQRS EntityBehavior.
38
-
typeEntityBehavior[TState]interface {
38
+
typeEntityBehaviorinterface {
39
39
// ID defines the id that will be used in the event journal.
40
40
// This helps track the entity in the events store.
41
41
ID() string
42
42
// InitialState returns the event sourced actor initial state.
43
43
// This is set as the initial state when there are no snapshots found the entity
44
-
InitialState() T
44
+
InitialState() State
45
45
// HandleCommand helps handle commands received by the event sourced actor. The command handlers define how to handle each incoming command,
46
46
// which validations must be applied, and finally, which events will be persisted if any. When there is no event to be persisted a nil can
47
47
// be returned as a no-op. Command handlers are the meat of the event sourced actor.
@@ -53,8 +53,8 @@ type EntityBehavior[T State] interface {
53
53
// Every event emitted are processed one after the other in the same order they were emitted to guarantee consistency.
54
54
// It is at the discretion of the application developer to know in which order a given command should return the list of events
55
55
// This is really powerful when a command needs to return two events. For instance, an OpenAccount command can result in two events: one is AccountOpened and the second is AccountCredited
// HandleEvent handle events emitted by the command handlers. The event handlers are used to mutate the state of the event sourced actor by applying the events to it.
58
58
// Event handlers must be pure functions as they will be used when instantiating the event sourced actor and replaying the event journal.
0 commit comments