Documentation
¶
Index ¶
- Variables
- type Aggregator
- type BSONSerializer
- type Event
- func (evt *Event) GetAggregateId() string
- func (evt *Event) GetAggregateType() string
- func (evt *Event) GetPayload() Payload
- func (evt *Event) GetReason() string
- func (evt *Event) GetSerializer() SerializerType
- func (evt *Event) GetTimestamp() Timestamp
- func (evt *Event) GetVersion() Version
- func (evt *Event) SetAggregateId(aggId string)
- func (evt *Event) SetAggregateType(aggType string)
- func (evt *Event) SetPayload(payload Payload)
- func (evt *Event) SetReason(reason string)
- func (evt *Event) SetSerializer(typ SerializerType)
- func (evt *Event) SetTimestamp(tstamp Timestamp)
- func (evt *Event) SetVersion(version Version)
- type Eventer
- type JSONSerializer
- type Payload
- type Serializer
- type SerializerType
- type Timestamp
- type Transition
- type UnsupportedSerializer
- type Version
Constants ¶
This section is empty.
Variables ¶
View Source
var MatchedSerializers = map[SerializerType]Serializer{ SerializerTypeJSON: &JSONSerializer{}, SerializerTypeBSON: &BSONSerializer{}, }
MatchedSerializers represents all currently available serializers.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator interface { // GetID gets aggregate root id. GetId() string // SetID sets aggregate root id. SetId(id string) // GetType gets aggregate root type. GetType() string // SetType sets aggregate root type. SetType(typ string) // GetVerion gets current aggregate root version. GetVersion() Version // SetVersions sets current aggregate root version. SetVersion(version Version) // ListCommittedEvents returns list of all committed events. ListCommittedEvents() []Eventer // ListUncommittedEvents returns list of all uncommitted yet events. ListUncommittedEvents() []Eventer // Apply applies not committed yet event into aggregate root. Sets event // id, type and version same as current aggregate root state. Apply(event Eventer) error // ApplyCommitted applies already committed event into aggregate root. Sets // aggregate root id, type and version the same as current applied event. ApplyCommitted(event Eventer) error // Commit marks provided event as committed and removes // from uncommitted events list. Commit(event Eventer) error }
Aggregator is main interface that responsibles for event aggregation. Aggregate is a cluster of associated objects treated as a single unit.
type BSONSerializer ¶
type BSONSerializer struct{}
func (BSONSerializer) Decode ¶
func (BSONSerializer) Decode(data Payload, dst interface{}) error
func (BSONSerializer) Encode ¶
func (BSONSerializer) Encode(v interface{}) (Payload, error)
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func NewWithSerializer ¶
func NewWithSerializer(reason string, payload interface{}, serializerType SerializerType) (*Event, error)
func (*Event) GetAggregateId ¶
func (*Event) GetAggregateType ¶
func (*Event) GetPayload ¶
func (*Event) GetSerializer ¶
func (evt *Event) GetSerializer() SerializerType
func (*Event) GetTimestamp ¶
func (*Event) GetVersion ¶
func (*Event) SetAggregateId ¶
func (*Event) SetAggregateType ¶
func (*Event) SetPayload ¶
func (*Event) SetSerializer ¶
func (evt *Event) SetSerializer(typ SerializerType)
func (*Event) SetTimestamp ¶
func (*Event) SetVersion ¶
type Eventer ¶
type Eventer interface { GetAggregateId() string SetAggregateId(id string) GetAggregateType() string SetAggregateType(typ string) GetReason() string SetReason(reason string) GetVersion() Version SetVersion(version Version) GetTimestamp() Timestamp SetTimestamp(tstamp Timestamp) GetPayload() Payload SetPayload(payload Payload) GetSerializer() SerializerType SetSerializer(s SerializerType) }
Eventer is a main interface with all basic getters/setters that responsibles for event manipulation.
func Covarience ¶
type JSONSerializer ¶
type JSONSerializer struct{}
func (JSONSerializer) Decode ¶
func (JSONSerializer) Decode(data Payload, dst interface{}) error
func (JSONSerializer) Encode ¶
func (JSONSerializer) Encode(v interface{}) (Payload, error)
type Serializer ¶
type SerializerType ¶
type SerializerType string
const ( SerializerTypeJSON SerializerType = "json" SerializerTypeBSON SerializerType = "bson" )
type Transition ¶
Transition is a type that makes transition on already known event reason.
type UnsupportedSerializer ¶
type UnsupportedSerializer struct{}
func (UnsupportedSerializer) Decode ¶
func (UnsupportedSerializer) Decode(data Payload, dst interface{}) error
func (UnsupportedSerializer) Encode ¶
func (UnsupportedSerializer) Encode(v interface{}) (Payload, error)
Click to show internal directories.
Click to hide internal directories.