eventstore

package module
v0.0.0-...-10b4966 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-eventstore

Basic event store implementation on Golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor struct {
	ID   string                 `json:"id" bson:"id"`                         // required
	Type string                 `json:"type,omitempty" bson:"type,omitempty"` // optional, but recommended
	Name string                 `json:"name,omitempty" bson:"name,omitempty"` // optional, but recommended
	Data map[string]interface{} `json:"data,omitempty" bson:"data,omitempty"` // optional, additional data about the actor. This can be used to store information about the actor that is not part of the event., for example the actor's IP address, user agent, etc.
}

Actor is a struct that contains information about the actor that caused the event.

type Event

type Event struct {
	// ID represents a unique identifier for the event. It allows for the event to be uniquely identified and referenced within the system.
	ID string `json:"id" bson:"_id"`
	// Metadata properties provide additional context or information about the event.
	Metadata Metadata `json:"metadata" bson:"metadata"`
	// The EventData property is an encoded JSON object that contains the actual data or payload of the event.
	EventData []byte `json:"event_data,omitempty" bson:"event_data,omitempty"`
}

Event is a struct that contains information about the event.

func NewEvent

func NewEvent(eventPayload interface{}, metadata Metadata) (*Event, error)

NewEvent creates a new event. The event ID is generated automatically. eventPayload is the actual data or payload of the event. It can be any type that can be encoded as JSON.

type EventStore

type EventStore interface {
	// Save saves the events in the event store.
	Save(ctx context.Context, events ...Event) error
	// Load loads the events from the event store.
	Load(ctx context.Context, filter LoadingFilter) ([]interface{}, error)
}

EventStore is an interface for storing and retrieving events.

type LoadingFilter

type LoadingFilter struct {
	// The aggregate ID property identifies the specific aggregate to which the event belongs.
	AggregateID *string
	// The AggregateType property identifies the type or class of the aggregate to which the event belongs. It specifies the entity or cluster of related entities that the event affects or is associated with.
	AggregateType *string
	// Event types can be used to filter events by type.
	EventType *string
	// SinceEventVersion can be used to filter events by version number. It will return all events with a version number greater than or equal to the specified version number.
	SinceEventVersion *int64
	// UntilEventVersion can be used to filter events by version number. It will return all events with a version number less than or equal to the specified version number.
	UntilEventVersion *int64
}

LoadingFilter is a struct that contains the filter options for loading events from the event store.

type Metadata

type Metadata struct {
	// EventType indicates the nature or category of the event. It helps determine how the event should be processed and interpreted by the system.
	EventType string `json:"event_type" bson:"event_type"`
	// Events within an aggregate are often assigned a version or a sequence number. It helps maintain the order of events and allows for conflict resolution in cases of concurrent modifications.
	EventVersion int64 `json:"event_version" bson:"event_version"`
	// The EventTimestamp property represents the date and time when the event occurred.
	EventTimestamp int64 `json:"event_timestamp" bson:"event_timestamp"`
	// Correlation IDs can be useful for monitoring and analyzing business processes by aggregating and analyzing events with the same ID.
	EventCorrelationID string `json:"event_correlation_id,omitempty" bson:"event_correlation_id,omitempty"`
	// The aggregate ID property identifies the specific aggregate to which the event belongs.
	AggregateID string `json:"aggregate_id" bson:"aggregate_id"`
	// The AggregateType property identifies the type or class of the aggregate to which the event belongs. It specifies the entity or cluster of related entities that the event affects or is associated with.
	AggregateType string `json:"aggregate_type,omitempty" bson:"aggregate_type,omitempty"`
	// In systems where user interactions are captured as events, the user or actor property identifies the user or actor who initiated the action.
	Actor *Actor `json:"actor,omitempty" bson:"actor,omitempty"`
}

Metadata properties provide additional context or information about the event.

Jump to

Keyboard shortcuts

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