eventsource

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {
	Id() string
	Version() int64
	Commit() Commit
}

type AggregateRoot

type AggregateRoot struct {
	// contains filtered or unexported fields
}

func (*AggregateRoot) Apply

func (a *AggregateRoot) Apply(e Event)

func (*AggregateRoot) CommitEvents

func (a *AggregateRoot) CommitEvents(version int64, handler func(e Event))

func (*AggregateRoot) Id

func (a *AggregateRoot) Id() string

func (*AggregateRoot) LoadFromHistoricalEvents

func (a *AggregateRoot) LoadFromHistoricalEvents(stream Stream) *AggregateRoot

func (*AggregateRoot) Version

func (a *AggregateRoot) Version() int64

func (*AggregateRoot) WithHandler

func (a *AggregateRoot) WithHandler(handler EventHandler) *AggregateRoot

func (*AggregateRoot) WithId

func (a *AggregateRoot) WithId(id string) *AggregateRoot

func (*AggregateRoot) WithVersion

func (a *AggregateRoot) WithVersion(v int64) *AggregateRoot

type Commit

type Commit struct {
	// contains filtered or unexported fields
}

func NewCommit

func NewCommit(id string, sequence int64) *Commit

func (*Commit) Append

func (c *Commit) Append(event Event)

func (*Commit) Events

func (c *Commit) Events() EventList

func (*Commit) Id

func (c *Commit) Id() string

func (*Commit) Sequence

func (c *Commit) Sequence() int64

func (*Commit) SetTimestamp

func (c *Commit) SetTimestamp(timestamp string)

func (*Commit) Timestamp

func (c *Commit) Timestamp() string

type Event

type Event interface {
	// EventSequence returns the sequence number of this event
	EventSequence() int64

	// EventTimestamp returns the timestamp of the event
	EventTimestamp() string
	// contains filtered or unexported methods
}

type EventHandler

type EventHandler interface {
	On(e Event)
}

type EventList

type EventList []Event

type EventModel

type EventModel struct {
	// Sequence contains the event sequence number
	Sequence int64 `json:"seq"`

	// Timestamp contains the timestamp of the event
	Timestamp string `json:"ts"`
}

func (*EventModel) EventSequence

func (m *EventModel) EventSequence() int64

func (*EventModel) EventTimestamp

func (m *EventModel) EventTimestamp() string

type EventReplayer

type EventReplayer interface {
	Replay(eventList EventList) ReplayResult
}

type Record

type Record struct {
	// Data contains the event in serialized form
	Data []byte
}

Record provides the serialized representation of the event

type ReplayResult

type ReplayResult struct {
	Error error
}

func Replay

func Replay(handler EventHandler, eventList EventList) ReplayResult

func (ReplayResult) Failed

func (r ReplayResult) Failed() bool

type Repository

type Repository interface {
	Get(streamId string) (stream Stream, err error)
	Save(aggregate Aggregate) (events int, err error)
	Delete(stream Stream) (err error)
}

type Serializer

type Serializer interface {
	// MarshalEvent converts an Event to a Record
	MarshalEvent(event Event) (Record, error)

	// UnmarshalEvent converts an Event backed into a Record
	UnmarshalEvent(record Record) (Event, error)
}

Serializer converts between Events and Records

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func NewStream

func NewStream(id string, commits ...Commit) Stream

func (Stream) Commits

func (s Stream) Commits() []Commit

func (Stream) Events

func (s Stream) Events() (events []Event)

func (Stream) Id

func (s Stream) Id() string

func (Stream) Length

func (s Stream) Length() int64

func (Stream) Version

func (s Stream) Version() int64

Jump to

Keyboard shortcuts

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