tira

package module
v0.0.0-...-2d2e6bf Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EntityIDMetaKey = "EntityID"

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {

	// Evolver means aggregates can be evolved with events
	rita.Evolver

	// Entity means aggregates have identity
	Entity
}

Aggregate defines core behaviour of an aggregate.

Can evolve based on events and has identity.

type Entity

type Entity interface {
	EntityID() EntityID
}

Entity represents any struct or type that are identified by an EntityID.

type EntityID

type EntityID string

type EventStore

type EventStore[T rita.Evolver] interface {
	// Append event to stream
	//
	// expectSequence must be correct in order for the event to be appended.
	//If this event is expected to be the first for given entity then set expectSequence to zero.
	Append(
		ctx context.Context,
		id EntityID,
		data any,
		expectSequence uint64,
	) (uint64, error)

	// Load and evolve entity into given target.
	Load(
		ctx context.Context,
		id EntityID,
		target T,
	) (uint64, error)
}

func NewEventStore

func NewEventStore[T rita.Evolver](nc *nats.Conn, registry *types.Registry, streamName StreamName) (
	EventStore[T],
	error,
)

type StreamName

type StreamName string

func (StreamName) Subject

func (name StreamName) Subject() string

Jump to

Keyboard shortcuts

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