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 ¶
var ( ErrInvalidFirstName = errors.New("user: invalid first name, is empty") ErrInvalidLastName = errors.New("user: invalid last name, is empty") ErrInvalidEmail = errors.New("user: invalid email name, is empty") ErrInvalidBirthDate = errors.New("user: invalid birthdate, is empty") )
All the errors returned by User methods.
var EventProtoSerde = serde.Fused[message.Message, *userv1.Event]{ Serializer: serde.SerializerFunc[message.Message, *userv1.Event](protoEventSerializer), Deserializer: serde.DeserializerFunc[message.Message, *userv1.Event](protoEventDeserializer), }
EventProtoSerde is the serde.Serde implementation for User domain events to map to their Protobuf type, defined in the proto/ folder.
var ProtoSerde = serde.Fused[*User, *userv1.User]{ Serializer: serde.SerializerFunc[*User, *userv1.User](protoSerializer), Deserializer: serde.DeserializerFunc[*User, *userv1.User](protoDeserializer), }
ProtoSerde is the serde.Serde implementation for a User to map to its Protobuf type, defined in the proto/ folder.
var Type = aggregate.Type[uuid.UUID, *User]{ Name: "User", Factory: func() *User { return new(User) }, }
Type is the User aggregate type.
Functions ¶
func AggregateRepositorySuite ¶
AggregateRepositorySuite returns an executable testing suite running on the agfgregate.Repository value provided in input.
The aggregate.Repository value requested should comply with the given signature.
Package user of this module exposes a Protobuf-based serde, which can be useful to test serialization and deserialization of data to the target repository implementation.
Types ¶
type CreateCommand ¶
CreateCommand is a domain command that can be used to create a new User.
type CreateCommandHandler ¶
type CreateCommandHandler struct { Clock func() time.Time UUIDGenerator func() uuid.UUID UserRepository aggregate.Saver[uuid.UUID, *User] }
CreateCommandHandler is the command handler for CreateCommand domain commands.
func (CreateCommandHandler) Handle ¶
func (h CreateCommandHandler) Handle(ctx context.Context, cmd command.Envelope[CreateCommand]) error
Handle implements command.Handler.
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 ¶
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, now time.Time) (*User, error)
Create creates a new User using the provided input.
func (*User) AggregateID ¶
AggregateID implements aggregate.Root.