user

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package user serves as a small domain example of how to model an Aggregate using go-eventually.

This package is used for integration tests in the parent module.

Index

Constants

This section is empty.

Variables

View Source
var EventProtoSerde = serde.Fused[message.Message, *proto.Event]{
	Serializer:   serde.SerializerFunc[message.Message, *proto.Event](protoEventSerializer),
	Deserializer: serde.DeserializerFunc[message.Message, *proto.Event](protoEventDeserializer),
}

EventProtoSerde is the serde.Serde implementation for User domain events to map to their Protobuf type, defined in the proto/ folder.

View Source
var ProtoSerde = serde.Fused[*User, *proto.User]{
	Serializer:   serde.SerializerFunc[*User, *proto.User](protoSerializer),
	Deserializer: serde.DeserializerFunc[*User, *proto.User](protoDeserializer),
}

ProtoSerde is the serde.Serde implementation for a User to map to its Protobuf type, defined in the proto/ folder.

View Source
var Type = aggregate.Type[uuid.UUID, *User]{
	Name:    "User",
	Factory: func() *User { return &User{} },
}

Type is the User aggregate type.

Functions

This section is empty.

Types

type EmailWasUpdated

type EmailWasUpdated struct {
	Email string
}

EmailWasUpdated is the domain event fired after a User email is updated.

func (EmailWasUpdated) Name

func (EmailWasUpdated) Name() string

Name implements message.Message.

type User

type User struct {
	aggregate.BaseRoot
	// contains filtered or unexported fields
}

User is a naive user implementation, modeled as an Aggregate using go-eventually's API.

func Create

func Create(id uuid.UUID, firstName, lastName, email string, birthDate time.Time) (*User, error)

Create creates a new User using the provided input.

func (*User) AggregateID

func (user *User) AggregateID() uuid.UUID

AggregateID implements aggregate.Root.

func (*User) Apply

func (user *User) Apply(evt event.Event) error

Apply implements aggregate.Aggregate.

func (*User) UpdateEmail

func (user *User) UpdateEmail(email string, metadata message.Metadata) error

UpdateEmail updates the User email with the specified one.

type WasCreated

type WasCreated struct {
	ID        uuid.UUID
	FirstName string
	LastName  string
	BirthDate time.Time
	Email     string
}

WasCreated is the domain event fired after a User is created.

func (WasCreated) Name

func (WasCreated) Name() string

Name implements message.Message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL