Documentation ¶
Index ¶
- Variables
- type AggregateHandler
- type BaseAggregate
- func (b *BaseAggregate) ApplyChangeHelper(ctx context.Context, aggregate AggregateHandler, event *Event, commit bool) error
- func (b *BaseAggregate) ClearUncommitted()
- func (*BaseAggregate) Descriptor() ([]byte, []int)deprecated
- func (x *BaseAggregate) GetChanges() []*Event
- func (x *BaseAggregate) GetFieldMask() *fieldmaskpb.FieldMask
- func (x *BaseAggregate) GetId() string
- func (x *BaseAggregate) GetType() string
- func (x *BaseAggregate) GetVersion() int32
- func (b *BaseAggregate) IncrementVersion()
- func (*BaseAggregate) ProtoMessage()
- func (x *BaseAggregate) ProtoReflect() protoreflect.Message
- func (x *BaseAggregate) Reset()
- func (x *BaseAggregate) String() string
- func (b *BaseAggregate) Uncommitted() []*Event
- type BaseCommand
- func (*BaseCommand) Descriptor() ([]byte, []int)deprecated
- func (x *BaseCommand) GetAggregateId() string
- func (x *BaseCommand) GetAggregateType() string
- func (x *BaseCommand) GetPayload() string
- func (x *BaseCommand) GetType() string
- func (x *BaseCommand) GetVersion() int32
- func (*BaseCommand) ProtoMessage()
- func (x *BaseCommand) ProtoReflect() protoreflect.Message
- func (x *BaseCommand) Reset()
- func (x *BaseCommand) String() string
- type CommandHandle
- type Event
- func (*Event) Descriptor() ([]byte, []int)deprecated
- func (x *Event) GetAggregateId() string
- func (x *Event) GetAggregateType() string
- func (x *Event) GetCreatedAt() *timestamppb.Timestamp
- func (x *Event) GetId() string
- func (x *Event) GetPayload() string
- func (x *Event) GetType() string
- func (x *Event) GetUpdatedAt() *timestamppb.Timestamp
- func (x *Event) GetVersion() int32
- func (*Event) ProtoMessage()
- func (x *Event) ProtoReflect() protoreflect.Message
- func (x *Event) Reset()
- func (x *Event) String() string
- type Snapshot
- func (*Snapshot) Descriptor() ([]byte, []int)deprecated
- func (x *Snapshot) GetAggregateId() string
- func (x *Snapshot) GetAggregateType() string
- func (x *Snapshot) GetAggregateVersion() int32
- func (x *Snapshot) GetCreatedAt() *timestamppb.Timestamp
- func (x *Snapshot) GetPayload() string
- func (x *Snapshot) GetUpdatedAt() *timestamppb.Timestamp
- func (*Snapshot) ProtoMessage()
- func (x *Snapshot) ProtoReflect() protoreflect.Message
- func (x *Snapshot) Reset()
- func (x *Snapshot) String() string
Constants ¶
This section is empty.
Variables ¶
var File_domain_eventsourcing_v1_aggregate_proto protoreflect.FileDescriptor
var File_domain_eventsourcing_v1_command_proto protoreflect.FileDescriptor
var File_domain_eventsourcing_v1_event_proto protoreflect.FileDescriptor
var File_domain_eventsourcing_v1_snapshot_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type AggregateHandler ¶
type AggregateHandler interface { ApplyChange(ctx context.Context, event *Event) error ApplyChangeHelper(ctx context.Context, aggregate AggregateHandler, event *Event, commit bool) error HandleCommand(ctx context.Context, command *BaseCommand) error Uncommitted() []*Event ClearUncommitted() IncrementVersion() }
AggregateHandler defines the methods to process commands
type BaseAggregate ¶
type BaseAggregate struct { // Field mask indicating which fields have been updated. FieldMask *fieldmaskpb.FieldMask `protobuf:"bytes,5,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"` // The unique identifier of the aggregate. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The type of the aggregate. Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // The version of the aggregate. Version int32 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` // The changes that have been made to the aggregate, represented as a list of events. Changes []*Event `protobuf:"bytes,4,rep,name=changes,proto3" json:"changes,omitempty"` // contains filtered or unexported fields }
BaseAggregate represents the basic information that all aggregates should have.
func (*BaseAggregate) ApplyChangeHelper ¶
func (b *BaseAggregate) ApplyChangeHelper(ctx context.Context, aggregate AggregateHandler, event *Event, commit bool) error
ApplyChangeHelper increments the version of an aggregate and apply the change itself
func (*BaseAggregate) ClearUncommitted ¶
func (b *BaseAggregate) ClearUncommitted()
ClearUncommited the events
func (*BaseAggregate) Descriptor
deprecated
func (*BaseAggregate) Descriptor() ([]byte, []int)
Deprecated: Use BaseAggregate.ProtoReflect.Descriptor instead.
func (*BaseAggregate) GetChanges ¶
func (x *BaseAggregate) GetChanges() []*Event
func (*BaseAggregate) GetFieldMask ¶
func (x *BaseAggregate) GetFieldMask() *fieldmaskpb.FieldMask
func (*BaseAggregate) GetId ¶
func (x *BaseAggregate) GetId() string
func (*BaseAggregate) GetType ¶
func (x *BaseAggregate) GetType() string
func (*BaseAggregate) GetVersion ¶
func (x *BaseAggregate) GetVersion() int32
func (*BaseAggregate) IncrementVersion ¶
func (b *BaseAggregate) IncrementVersion()
IncrementVersion ads 1 to the current version
func (*BaseAggregate) ProtoMessage ¶
func (*BaseAggregate) ProtoMessage()
func (*BaseAggregate) ProtoReflect ¶
func (x *BaseAggregate) ProtoReflect() protoreflect.Message
func (*BaseAggregate) Reset ¶
func (x *BaseAggregate) Reset()
func (*BaseAggregate) String ¶
func (x *BaseAggregate) String() string
func (*BaseAggregate) Uncommitted ¶
func (b *BaseAggregate) Uncommitted() []*Event
Uncommitted return the events to be saved
type BaseCommand ¶
type BaseCommand struct { // The type of the command. Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // AggregateID represents the id of the aggregate to apply to. AggregateId string `protobuf:"bytes,2,opt,name=aggregate_id,json=aggregateId,proto3" json:"aggregate_id,omitempty"` // The type of the aggregate to apply the command to. AggregateType string `protobuf:"bytes,3,opt,name=aggregate_type,json=aggregateType,proto3" json:"aggregate_type,omitempty"` // The version of the command. Version int32 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` // The payload of the command. Payload string `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
BaseCommand represents the basic information that all commands should have.
func (*BaseCommand) Descriptor
deprecated
func (*BaseCommand) Descriptor() ([]byte, []int)
Deprecated: Use BaseCommand.ProtoReflect.Descriptor instead.
func (*BaseCommand) GetAggregateId ¶
func (x *BaseCommand) GetAggregateId() string
func (*BaseCommand) GetAggregateType ¶
func (x *BaseCommand) GetAggregateType() string
func (*BaseCommand) GetPayload ¶
func (x *BaseCommand) GetPayload() string
func (*BaseCommand) GetType ¶
func (x *BaseCommand) GetType() string
func (*BaseCommand) GetVersion ¶
func (x *BaseCommand) GetVersion() int32
func (*BaseCommand) ProtoMessage ¶
func (*BaseCommand) ProtoMessage()
func (*BaseCommand) ProtoReflect ¶
func (x *BaseCommand) ProtoReflect() protoreflect.Message
func (*BaseCommand) Reset ¶
func (x *BaseCommand) Reset()
func (*BaseCommand) String ¶
func (x *BaseCommand) String() string
type CommandHandle ¶
type CommandHandle interface { Handle(ctx context.Context, in any) (*BaseCommand, error) PublishEvents(ctx context.Context, events []*Event) error }
CommandHandle defines the contract to handle commands
type Event ¶
type Event struct { // The unique identifier of the aggregate. AggregateId string `protobuf:"bytes,1,opt,name=aggregate_id,json=aggregateId,proto3" json:"aggregate_id,omitempty"` // The type of the aggregate. AggregateType string `protobuf:"bytes,2,opt,name=aggregate_type,json=aggregateType,proto3" json:"aggregate_type,omitempty"` // The unique identifier of the event. Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` // The version of the event. Version int32 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` // The type of the event. Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` // The payload of the event. Payload string `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` // The timestamp when the event was created. CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // The timestamp when the event was last updated. UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // contains filtered or unexported fields }
Event represents a change that happened to the Aggregate.
func (*Event) Descriptor
deprecated
func (*Event) GetAggregateId ¶
func (*Event) GetAggregateType ¶
func (*Event) GetCreatedAt ¶
func (x *Event) GetCreatedAt() *timestamppb.Timestamp
func (*Event) GetPayload ¶
func (*Event) GetUpdatedAt ¶
func (x *Event) GetUpdatedAt() *timestamppb.Timestamp
func (*Event) GetVersion ¶
func (*Event) ProtoMessage ¶
func (*Event) ProtoMessage()
func (*Event) ProtoReflect ¶
func (x *Event) ProtoReflect() protoreflect.Message
type Snapshot ¶
type Snapshot struct { // The unique identifier of the aggregate. AggregateId string `protobuf:"bytes,1,opt,name=aggregate_id,json=aggregateId,proto3" json:"aggregate_id,omitempty"` // The type of the aggregate. AggregateType string `protobuf:"bytes,2,opt,name=aggregate_type,json=aggregateType,proto3" json:"aggregate_type,omitempty"` // The version of the aggregate at the time of the snapshot. AggregateVersion int32 `protobuf:"varint,3,opt,name=aggregate_version,json=aggregateVersion,proto3" json:"aggregate_version,omitempty"` // The payload of the snapshot, representing the state of the aggregate. Payload string `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` // The timestamp when the snapshot was created. CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // The timestamp when the snapshot was last updated. UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // contains filtered or unexported fields }
Snapshot represents a snapshot of the state of an aggregate at a specific point in time.
func (*Snapshot) Descriptor
deprecated
func (*Snapshot) GetAggregateId ¶
func (*Snapshot) GetAggregateType ¶
func (*Snapshot) GetAggregateVersion ¶
func (*Snapshot) GetCreatedAt ¶
func (x *Snapshot) GetCreatedAt() *timestamppb.Timestamp
func (*Snapshot) GetPayload ¶
func (*Snapshot) GetUpdatedAt ¶
func (x *Snapshot) GetUpdatedAt() *timestamppb.Timestamp
func (*Snapshot) ProtoMessage ¶
func (*Snapshot) ProtoMessage()
func (*Snapshot) ProtoReflect ¶
func (x *Snapshot) ProtoReflect() protoreflect.Message