Documentation ¶
Index ¶
- Constants
- type Command
- func CommandWithMetadata(c *Command, m map[string]interface{}) *Command
- func CommandWithVersion(c *Command, v uint64) *Command
- func NewCommand(id, name string, data interface{}, metadata map[string]interface{}, ...) *Command
- func NewCommandFromContext(ctx context.Context, id, name string, data interface{}, ...) *Command
- type DomainMessage
- func (*DomainMessage) Descriptor() ([]byte, []int)
- func (m *DomainMessage) GetCreated() *timestamp.Timestamp
- func (m *DomainMessage) GetData() []byte
- func (m *DomainMessage) GetMessageId() string
- func (m *DomainMessage) GetMessageName() string
- func (m *DomainMessage) GetMetadata() map[string][]byte
- func (m *DomainMessage) GetVersion() uint64
- func (*DomainMessage) ProtoMessage()
- func (m *DomainMessage) Reset()
- func (m *DomainMessage) String() string
- func (m *DomainMessage) XXX_DiscardUnknown()
- func (m *DomainMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DomainMessage) XXX_Merge(src proto.Message)
- func (m *DomainMessage) XXX_Size() int
- func (m *DomainMessage) XXX_Unmarshal(b []byte) error
- type Event
- func EventWithMetadata(e *Event, m map[string]interface{}) *Event
- func EventWithVersion(e *Event, v uint64) *Event
- func NewAggregateEvent(ctx context.Context, aggregateID string, aggregateVersion uint64, ...) *Event
- func NewEvent(id, name string, data interface{}, metadata map[string]interface{}, ...) *Event
- func NewEventFromContext(ctx context.Context, id, name string, data interface{}, ...) *Event
- type JSONMessage
- type JSONMessageFactory
- type JSONMessageWrapper
- func (m *JSONMessageWrapper) Created() time.Time
- func (m *JSONMessageWrapper) Data() interface{}
- func (m *JSONMessageWrapper) MessageID() string
- func (m *JSONMessageWrapper) MessageName() string
- func (m *JSONMessageWrapper) Metadata() map[string]interface{}
- func (m *JSONMessageWrapper) Version() uint64
- type Message
- type MessageFactory
- type PayloadBuilder
- type ProtoMessageFactory
- type ProtoMessageWrapper
- func (m *ProtoMessageWrapper) Created() time.Time
- func (m *ProtoMessageWrapper) Data() interface{}
- func (m *ProtoMessageWrapper) MessageID() string
- func (m *ProtoMessageWrapper) MessageName() string
- func (m *ProtoMessageWrapper) Metadata() map[string]interface{}
- func (m *ProtoMessageWrapper) Version() uint64
- type TestPayload
- func (*TestPayload) Descriptor() ([]byte, []int)
- func (m *TestPayload) GetABool() bool
- func (m *TestPayload) GetAInt() int64
- func (m *TestPayload) GetAString() string
- func (*TestPayload) ProtoMessage()
- func (m *TestPayload) Reset()
- func (m *TestPayload) String() string
- func (m *TestPayload) XXX_DiscardUnknown()
- func (m *TestPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TestPayload) XXX_Merge(src proto.Message)
- func (m *TestPayload) XXX_Size() int
- func (m *TestPayload) XXX_Unmarshal(b []byte) error
Constants ¶
const ( // MetaCausationID should be set on a context where a command // is called, this will allow us to pull the command id out and // set it as the causation ID. // Read more: https://blog.arkency.com/correlation-id-and-causation-id-in-evented-systems/ MetaCausationID metaKey = "causation_id" // MetaCorrelationID if another event caused this new event we should // set that as the correlation id on the event's metadata. // Read more: https://blog.arkency.com/correlation-id-and-causation-id-in-evented-systems/ MetaCorrelationID metaKey = "correlation_id" // MetaAggregateID is the identifier of an aggregate, used when using event sourcing. MetaAggregateID metaKey = "aggregate_id" // MetaAggregateVersion should be set on an event for the version it is targeting, for // example if you've loaded an aggregate at version 6 the next version should be 7. // Versions start from 1! MetaAggregateVersion metaKey = "aggregate_version" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command describes something that has happened.
func CommandWithMetadata ¶
CommandWithMetadata returns an command copied from the previous command with the updated metadata.
func CommandWithVersion ¶
CommandWithVersion returns an command copied from the previous command with the updated version.
func NewCommand ¶
func NewCommand(id, name string, data interface{}, metadata map[string]interface{}, version uint64, created time.Time) *Command
NewCommand will return an immutable command.
func NewCommandFromContext ¶
func NewCommandFromContext(ctx context.Context, id, name string, data interface{}, metadata map[string]interface{}, version uint64, created time.Time) *Command
NewCommandFromContext will return an immutable command, filling metadata with any information that we know can be added to commands such as causation id.
func (*Command) Data ¶
func (c *Command) Data() interface{}
Data will return information related to the command.
func (*Command) MessageName ¶
MessageName returns the name of the message.
type DomainMessage ¶
type DomainMessage struct { // Identitifer for message. MessageId string `protobuf:"bytes,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` // The name of the message. MessageName string `protobuf:"bytes,2,opt,name=message_name,json=messageName,proto3" json:"message_name,omitempty"` // The message payload. Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // Metadata associated to the message. Metadata map[string][]byte `` /* 157-byte string literal not displayed */ // The version of the domain message. Version uint64 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` // When the domain message was first created. Created *timestamp.Timestamp `protobuf:"bytes,6,opt,name=created,proto3" json:"created,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Used to seralise messages for storaging and transfering.
func (*DomainMessage) Descriptor ¶
func (*DomainMessage) Descriptor() ([]byte, []int)
func (*DomainMessage) GetCreated ¶
func (m *DomainMessage) GetCreated() *timestamp.Timestamp
func (*DomainMessage) GetData ¶
func (m *DomainMessage) GetData() []byte
func (*DomainMessage) GetMessageId ¶
func (m *DomainMessage) GetMessageId() string
func (*DomainMessage) GetMessageName ¶
func (m *DomainMessage) GetMessageName() string
func (*DomainMessage) GetMetadata ¶
func (m *DomainMessage) GetMetadata() map[string][]byte
func (*DomainMessage) GetVersion ¶
func (m *DomainMessage) GetVersion() uint64
func (*DomainMessage) ProtoMessage ¶
func (*DomainMessage) ProtoMessage()
func (*DomainMessage) Reset ¶
func (m *DomainMessage) Reset()
func (*DomainMessage) String ¶
func (m *DomainMessage) String() string
func (*DomainMessage) XXX_DiscardUnknown ¶
func (m *DomainMessage) XXX_DiscardUnknown()
func (*DomainMessage) XXX_Marshal ¶
func (m *DomainMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DomainMessage) XXX_Merge ¶
func (m *DomainMessage) XXX_Merge(src proto.Message)
func (*DomainMessage) XXX_Size ¶
func (m *DomainMessage) XXX_Size() int
func (*DomainMessage) XXX_Unmarshal ¶
func (m *DomainMessage) XXX_Unmarshal(b []byte) error
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event describes something that has happened.
func EventWithMetadata ¶
EventWithMetadata returns an event copied from the previous event with the updated metadata.
func EventWithVersion ¶
EventWithVersion returns an event copied from the previous event with the updated version.
func NewAggregateEvent ¶
func NewAggregateEvent(ctx context.Context, aggregateID string, aggregateVersion uint64, eventName string, data interface{}) *Event
NewAggregateEvent created a new event for an aggregate.
func NewEvent ¶
func NewEvent(id, name string, data interface{}, metadata map[string]interface{}, version uint64, created time.Time) *Event
NewEvent will return an immutable event.
func NewEventFromContext ¶
func NewEventFromContext(ctx context.Context, id, name string, data interface{}, metadata map[string]interface{}, version uint64, created time.Time) *Event
NewEventFromContext will return an immutable event, filling metadata with any information that we know can be added to events such as causation id.
func (*Event) Data ¶
func (e *Event) Data() interface{}
Data will return information related to the event.
func (*Event) MessageName ¶
MessageName returns the name of the message.
type JSONMessage ¶
type JSONMessageFactory ¶
type JSONMessageFactory struct {
// contains filtered or unexported fields
}
func NewJSONMessageFactory ¶
func NewJSONMessageFactory() *JSONMessageFactory
NewJSONMessageFactory will return a new message factory that serializes and unserialises JSON payloads.
func (*JSONMessageFactory) Build ¶
func (f *JSONMessageFactory) Build(msgName string, pl []byte) (interface{}, bool)
Build ...
func (*JSONMessageFactory) Builds ¶
func (f *JSONMessageFactory) Builds(name string, factory dataTypeFactory)
Builds ...
func (*JSONMessageFactory) Serialize ¶
func (f *JSONMessageFactory) Serialize(m Message) ([]byte, error)
Serialize ...
func (*JSONMessageFactory) Unserialize ¶
func (f *JSONMessageFactory) Unserialize(m []byte) (Message, error)
Unserialize ...
type JSONMessageWrapper ¶
type JSONMessageWrapper struct {
// contains filtered or unexported fields
}
func (*JSONMessageWrapper) MessageID ¶
func (m *JSONMessageWrapper) MessageID() string
MessageID ...
func (*JSONMessageWrapper) MessageName ¶
func (m *JSONMessageWrapper) MessageName() string
MessageName ...
func (*JSONMessageWrapper) Metadata ¶
func (m *JSONMessageWrapper) Metadata() map[string]interface{}
Metadata ...
type Message ¶
type Message interface { // MessageID returns the id of the message. MessageID() string // MessageName returns the name of the message. MessageName() string // Data will return information related to the event. Data() interface{} // Metadata will return metadata about the event. Metadata() map[string]interface{} // Version returns the version of the event. Version() uint64 // Created returns the time the event was created. Created() time.Time }
Message provides base functionality to commands, events and queries.
type MessageFactory ¶
type MessageFactory interface { Serialize(Message) ([]byte, error) Unserialize([]byte) (Message, error) }
MessageFactory ...
type PayloadBuilder ¶
type PayloadBuilder interface { Build(msgName string, pl []byte) (interface{}, bool) Builds(msgName string, with dataTypeFactory) }
PayloadBuilder ...
type ProtoMessageFactory ¶
type ProtoMessageFactory struct{}
func NewProtoMessageFactory ¶
func NewProtoMessageFactory() *ProtoMessageFactory
NewProtoMessageFactory will return a new message factory that serializes and unserialises Proto payloads.
func (*ProtoMessageFactory) Build ¶
func (f *ProtoMessageFactory) Build(msgName string, pl []byte) (interface{}, bool)
Build ...
func (*ProtoMessageFactory) Builds ¶
func (f *ProtoMessageFactory) Builds(name string, factory dataTypeFactory)
Builds is obsolete for protobuff as the generated Go library registers the messages itself.
func (*ProtoMessageFactory) Serialize ¶
func (f *ProtoMessageFactory) Serialize(m Message) ([]byte, error)
Serialize ...
func (*ProtoMessageFactory) Unserialize ¶
func (f *ProtoMessageFactory) Unserialize(m []byte) (Message, error)
Unserialize ...
type ProtoMessageWrapper ¶
type ProtoMessageWrapper struct {
// contains filtered or unexported fields
}
func (*ProtoMessageWrapper) MessageID ¶
func (m *ProtoMessageWrapper) MessageID() string
MessageID ...
func (*ProtoMessageWrapper) MessageName ¶
func (m *ProtoMessageWrapper) MessageName() string
MessageName ...
func (*ProtoMessageWrapper) Metadata ¶
func (m *ProtoMessageWrapper) Metadata() map[string]interface{}
Metadata ...
type TestPayload ¶
type TestPayload struct { AString string `protobuf:"bytes,1,opt,name=a_string,json=aString,proto3" json:"a_string,omitempty"` AInt int64 `protobuf:"varint,2,opt,name=a_int,json=aInt,proto3" json:"a_int,omitempty"` ABool bool `protobuf:"varint,3,opt,name=a_bool,json=aBool,proto3" json:"a_bool,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*TestPayload) Descriptor ¶
func (*TestPayload) Descriptor() ([]byte, []int)
func (*TestPayload) GetABool ¶
func (m *TestPayload) GetABool() bool
func (*TestPayload) GetAInt ¶
func (m *TestPayload) GetAInt() int64
func (*TestPayload) GetAString ¶
func (m *TestPayload) GetAString() string
func (*TestPayload) ProtoMessage ¶
func (*TestPayload) ProtoMessage()
func (*TestPayload) Reset ¶
func (m *TestPayload) Reset()
func (*TestPayload) String ¶
func (m *TestPayload) String() string
func (*TestPayload) XXX_DiscardUnknown ¶
func (m *TestPayload) XXX_DiscardUnknown()
func (*TestPayload) XXX_Marshal ¶
func (m *TestPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*TestPayload) XXX_Merge ¶
func (m *TestPayload) XXX_Merge(src proto.Message)
func (*TestPayload) XXX_Size ¶
func (m *TestPayload) XXX_Size() int
func (*TestPayload) XXX_Unmarshal ¶
func (m *TestPayload) XXX_Unmarshal(b []byte) error