v1

package
v0.0.0-...-36d8597 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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) Descriptor() ([]byte, []int)

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) GetAggregateId

func (x *Event) GetAggregateId() string

func (*Event) GetAggregateType

func (x *Event) GetAggregateType() string

func (*Event) GetCreatedAt

func (x *Event) GetCreatedAt() *timestamppb.Timestamp

func (*Event) GetId

func (x *Event) GetId() string

func (*Event) GetPayload

func (x *Event) GetPayload() string

func (*Event) GetType

func (x *Event) GetType() string

func (*Event) GetUpdatedAt

func (x *Event) GetUpdatedAt() *timestamppb.Timestamp

func (*Event) GetVersion

func (x *Event) GetVersion() int32

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect

func (x *Event) ProtoReflect() protoreflect.Message

func (*Event) Reset

func (x *Event) Reset()

func (*Event) String

func (x *Event) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Snapshot.ProtoReflect.Descriptor instead.

func (*Snapshot) GetAggregateId

func (x *Snapshot) GetAggregateId() string

func (*Snapshot) GetAggregateType

func (x *Snapshot) GetAggregateType() string

func (*Snapshot) GetAggregateVersion

func (x *Snapshot) GetAggregateVersion() int32

func (*Snapshot) GetCreatedAt

func (x *Snapshot) GetCreatedAt() *timestamppb.Timestamp

func (*Snapshot) GetPayload

func (x *Snapshot) GetPayload() string

func (*Snapshot) GetUpdatedAt

func (x *Snapshot) GetUpdatedAt() *timestamppb.Timestamp

func (*Snapshot) ProtoMessage

func (*Snapshot) ProtoMessage()

func (*Snapshot) ProtoReflect

func (x *Snapshot) ProtoReflect() protoreflect.Message

func (*Snapshot) Reset

func (x *Snapshot) Reset()

func (*Snapshot) String

func (x *Snapshot) String() string

Jump to

Keyboard shortcuts

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