ehpg

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 11 Imported by: 0

README

EventHorizon with REDIS

Features

  • EventStore
	
    options := redis.UniversalOptions{
		Addrs:              "localhost",
		DB:                 1,
		Password:           "mypassword",
	}

    db := redis.NewUniversalClient(&options)

    defer db.close()

    store, err := ehre.NewEventStore(db)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotClearDB = errors.New("could not clear database")

ErrCouldNotClearDB is when the database could not be cleared.

View Source
var ErrCouldNotMarshalEvent = errors.New("could not marshal event")

ErrCouldNotMarshalEvent is when an event could not be marshaled into JSON.

View Source
var ErrCouldNotSaveAggregate = errors.New("could not save aggregate")

ErrCouldNotSaveAggregate is when an aggregate could not be saved.

View Source
var ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal event")

ErrCouldNotUnmarshalEvent is when an event could not be unmarshalled into a concrete type.

View Source
var ErrVersionConflict = errors.New("can not create/update aggregate")

ErrConflictVersion is when a version conflict occurs when saving an aggregate.

View Source
var NewUUID = uuid.New

NewUUID for mocking in tests

Functions

This section is empty.

Types

type AggregateEvent

type AggregateEvent struct {
	EventID       uuid.UUID
	Namespace     string
	AggregateID   uuid.UUID
	AggregateType eh.AggregateType
	EventType     eh.EventType
	RawEventData  json.RawMessage
	Timestamp     time.Time
	Version       int
	Context       map[string]interface{}
	MetaData      map[string]interface{}

	RawMetaData json.RawMessage
	// contains filtered or unexported fields
}

func (AggregateEvent) MarshalBinary

func (a AggregateEvent) MarshalBinary() (data []byte, err error)

func (*AggregateEvent) UnmarshalBinary

func (a *AggregateEvent) UnmarshalBinary(data []byte) error

type AggregateRecord

type AggregateRecord struct {
	Namespace   string
	AggregateID uuid.UUID
	Version     int
}

type Encoder

type Encoder interface {
	Marshal(eh.EventData) ([]byte, error)
	Unmarshal(eh.EventType, []byte) (eh.EventData, error)
	String() string
}

type EventStore

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

EventStore implements an eh.EventStore for PostgreSQL.

func NewEventStore

func NewEventStore(db redis.UniversalClient) (*EventStore, error)

NewEventStore creates a new EventStore.

func (*EventStore) Clear

func (s *EventStore) Clear(ctx context.Context) error

Clear clears the event storage.

func (*EventStore) Close

func (s *EventStore) Close() error

func (*EventStore) Load

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

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

func (*EventStore) Save

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

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

Jump to

Keyboard shortcuts

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