Documentation ¶
Index ¶
- Variables
- type AggregateHandler
- type BaseAggregate
- func (b *BaseAggregate) ApplyChangeHelper(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 ¶
View Source
var File_eventsourcing_v1_aggregate_proto protoreflect.FileDescriptor
View Source
var File_eventsourcing_v1_command_proto protoreflect.FileDescriptor
View Source
var File_eventsourcing_v1_event_proto protoreflect.FileDescriptor
View Source
var File_eventsourcing_v1_snapshot_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type AggregateHandler ¶
type AggregateHandler interface { ApplyChange(event *Event) error ApplyChangeHelper(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 { FieldMask *fieldmaskpb.FieldMask `protobuf:"bytes,5,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` Version int32 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` Changes []*Event `protobuf:"bytes,4,rep,name=changes,proto3" json:"changes,omitempty"` // contains filtered or unexported fields }
BaseAggregate contains the basic info that all aggregates should have
func (*BaseAggregate) ApplyChangeHelper ¶
func (b *BaseAggregate) ApplyChangeHelper(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 { 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"` AggregateType string `protobuf:"bytes,3,opt,name=aggregate_type,json=aggregateType,proto3" json:"aggregate_type,omitempty"` Version int32 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` Payload string `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
BaseCommand contains the basic info 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 interface{}) (*BaseCommand, error) PublishEvents(ctx context.Context, events []*Event) error }
CommandHandle defines the contract to handle commands
type Event ¶
type Event struct { AggregateId string `protobuf:"bytes,1,opt,name=aggregate_id,json=aggregateId,proto3" json:"aggregate_id,omitempty"` AggregateType string `protobuf:"bytes,2,opt,name=aggregate_type,json=aggregateType,proto3" json:"aggregate_type,omitempty"` Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` Version int32 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"` Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` Payload string `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` // Create at CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // contains filtered or unexported fields }
Event describe 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 { AggregateId string `protobuf:"bytes,1,opt,name=aggregate_id,json=aggregateId,proto3" json:"aggregate_id,omitempty"` AggregateType string `protobuf:"bytes,2,opt,name=aggregate_type,json=aggregateType,proto3" json:"aggregate_type,omitempty"` AggregateVersion int32 `protobuf:"varint,3,opt,name=aggregate_version,json=aggregateVersion,proto3" json:"aggregate_version,omitempty"` Payload string `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` // Create at CreatedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // contains filtered or unexported fields }
Snapshot
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
Click to show internal directories.
Click to hide internal directories.