bun

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventStore

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

EventStore is an eventhorizon.EventStore for Bun

func NewEventStore

func NewEventStore(db bun.DB, options ...Option) (*EventStore, error)

NewEventStore creates a new EventStore with a bun.DB handle.

func (*EventStore) Close

func (eventStore *EventStore) Close() error

Close implements the Close method of the eventhorizon.EventStore interface.

func (*EventStore) Load

func (eventStore *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)

Load implements the Load method of the eventhorizon.EventStore interface.

func (*EventStore) LoadFrom

func (eventStore *EventStore) LoadFrom(ctx context.Context, id uuid.UUID, version int) ([]eh.Event, error)

LoadFrom implements the LoadFrom method of the eventhorizon.EventStore interface.

func (*EventStore) Save

func (eventStore *EventStore) Save(ctx context.Context, events []eh.Event, originalVersion int) error

Save implements the Save method of the eventhorizon.EventStore interface.

type Option

type Option func(*EventStore) error

Option is an option setter used to configure creation.

func WithEventHandler

func WithEventHandler(eventHandler eh.EventHandler) Option

WithEventHandler adds an event handler that will be called after saving events. An example would be to add an event bus to publish events.

func WithEventHandlerInTX

func WithEventHandlerInTX(eventHandler eh.EventHandler) Option

WithEventHandlerInTX adds an event handler that will be called during saving of events. An example would be to add an outbox to further process events. For an outbox to be atomic it needs to use the same transaction as the save operation, which is passed down using the context.

func WithTableCreate

func WithTableCreate() Option

func WithTableReset

func WithTableReset() Option

Jump to

Keyboard shortcuts

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