Documentation
¶
Overview ¶
package event implements functionality for working with an eventstore.
Index ¶
- Variables
- func Append(a Aggregate, lis ...Event)
- func EncodeEvents(events ...Event) (lis [][]byte, err error)
- func EventID(e Event) ulid.ULID
- func Init(ctx context.Context) error
- func MarshalBinary(e Event) ([]byte, error)
- func NotExists(a Aggregate) error
- func Raise(a Aggregate, lis ...Event)
- func Register(ctx context.Context, lis ...Event) error
- func RegisterName(ctx context.Context, name string, e Event) error
- func SetEventID(e Event, id ulid.ULID)
- func SetPosition(e Event, i uint64)
- func SetStreamID(id string, lis ...Event)
- func ShouldExist(a Aggregate) error
- func Start(a Aggregate, i uint64)
- func StreamID(e Event) streamID
- func TypeOf(e any) string
- func Values(e Event) map[string]any
- type AGG
- type Aggregate
- type AggregateRoot
- type Event
- type EventPtr
- type Events
- type FeedTruncated
- type IsAggregate
- type IsEvent
- type Meta
- type UnknownEvent
Constants ¶
This section is empty.
Variables ¶
var ErrShouldExist = errors.New("should exist")
var ErrShouldNotExist = errors.New("should not exist")
var NilEvent = &nilEvent{}
Functions ¶
func EncodeEvents ¶
func MarshalBinary ¶
func Register ¶
Register a type container for Unmarshalling values into. The type must implement Event and not be a nil value.
func SetEventID ¶
func SetPosition ¶
func SetStreamID ¶
func ShouldExist ¶
ShouldExists returns error if there are no events present.
Types ¶
type Aggregate ¶
type Aggregate interface {
// ApplyEvent applies the event to the aggrigate state
ApplyEvent(...Event)
AggregateRoot
}
Aggregate implements functionality for working with event store streams as an aggregate. When creating a new Aggregate the struct should have an ApplyEvent method and embed the AggregateRoot.
func AsAggregate ¶
type AggregateRoot ¶
type AggregateRoot interface {
// Events returns the aggregate events
// pass true for only uncommitted events
Events(bool) Events
// StreamID returns aggregate stream ID
StreamID() string
// SetStreamID sets aggregate stream ID
SetStreamID(streamID string)
// StreamVersion returns last commit events
StreamVersion() uint64
// Version returns the current aggrigate version. (committed + uncommitted)
Version() uint64
Commit()
// contains filtered or unexported methods
}
type Event ¶
Event implements functionality of an individual event used with the event store. It should implement the getter/setter for EventMeta and BinaryMarshaler/BinaryUnmarshaler.
type EventPtr ¶
func (*EventPtr) MarshalBinary ¶
MarshalBinary implements Event
func (*EventPtr) UnmarshalBinary ¶
UnmarshalBinary implements Event
type Events ¶
type Events []Event
Events is a list of events
func DecodeEvents ¶
DecodeEvents unmarshals the byte list into Events.
func (Events) SetStreamID ¶
type FeedTruncated ¶
type FeedTruncated struct {
IsEvent
}
func (*FeedTruncated) Values ¶
func (e *FeedTruncated) Values() any
type IsAggregate ¶
type IsAggregate struct {
// contains filtered or unexported fields
}
func (*IsAggregate) Commit ¶
func (a *IsAggregate) Commit()
func (*IsAggregate) Events ¶
func (a *IsAggregate) Events(new bool) Events
func (*IsAggregate) SetStreamID ¶
func (a *IsAggregate) SetStreamID(streamID string)
func (*IsAggregate) StreamID ¶
func (a *IsAggregate) StreamID() string
func (*IsAggregate) StreamVersion ¶
func (a *IsAggregate) StreamVersion() uint64
func (*IsAggregate) Version ¶
func (a *IsAggregate) Version() uint64
type Meta ¶
type Meta struct {
EventID ulid.ULID
StreamID string
Position uint64
ActualStreamID string
ActualPosition uint64
}
func (Meta) GetEventID ¶
type UnknownEvent ¶
type UnknownEvent struct {
IsEvent
// contains filtered or unexported fields
}
func NewUnknownEventFromRaw ¶
func NewUnknownEventFromRaw(eventType string, meta Meta, values map[string]json.RawMessage) *UnknownEvent
func NewUnknownEventFromValues ¶
func NewUnknownEventFromValues(eventType string, meta Meta, values url.Values) *UnknownEvent
func (UnknownEvent) EventType ¶
func (u UnknownEvent) EventType() string
func (*UnknownEvent) MarshalBinary ¶
func (u *UnknownEvent) MarshalBinary() ([]byte, error)
func (*UnknownEvent) UnmarshalBinary ¶
func (u *UnknownEvent) UnmarshalBinary(b []byte) error