Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Created ¶
type Created struct { ID string `json:"id"` // The id of the event (useful for deduplication purposes). OccurredOn time.Time `json:"occurred-on"` // The point in time when this event occurred. User UserID `json:"user"` // The id of the new User entity lifecycle. }
Created must be the very first event in a User entity lifecycle.
type NameChanged ¶
type NameChanged struct { ID string `json:"id"` // The id of the envent (useful for deduplication purposes). OccurredOn time.Time `json:"occurred-on"` // The point in time when this event occurred. User UserID `json:"user"` // The id of the User entity lifecycle. Name string `json:"name"` // The new name of the User going forward. }
NameChanged will always be generated when a Users name changes.
type Projection ¶
type Projection struct {
// contains filtered or unexported fields
}
Projection can answer some questions about the user domain.
func NewProjection ¶
func NewProjection() *Projection
NewProjection creates a new Projection. In a production system this should probably be something persistent.
func (*Projection) IsUserNameInUse ¶
func (p *Projection) IsUserNameInUse(name string) bool
IsUserNameInUse will check if the provided name is currently in use by a user.
func (*Projection) NumberOfNameChangesForUser ¶
func (p *Projection) NumberOfNameChangesForUser(id UserID) int
NumberOfNameChangesForUser will retrieve the number of name changes in history for a given user
func (*Projection) On ¶
func (p *Projection) On(rec event.Record)
On should be called for each event in history.
func (*Projection) TotalNumberOfNameChanges ¶
func (p *Projection) TotalNumberOfNameChanges() int
TotalNumberOfNameChanges will retrieve the total number of name changes in history
func (*Projection) UserName ¶
func (p *Projection) UserName(id UserID) string
UserName will retrieve a users current name.
type User ¶
type User struct { ID UserID // The id of the User entity. Version uint64 // The current version of the User entity. Name string // The current name of the User entity. *event.ChangeRecorder // The ChangeRecorder is embeded to track changes as a unit of work. }
User is an event sourced entity.
func (*User) ChangeName ¶
ChangeName is a command that should be called any time this users name should change.