store

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "EVENT_STORE"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// EventTypes is a list of supported event types. Events of other types will
	// be ignored.
	EventTypes []string
	// Storage is the storage implementation.
	Storage Storage
	// Transport is a transport interface used to fetch events from Oracles.
	Transport transport.Transport
	// Logger is a current logger interface used by the EventStore.
	// The Logger is required to monitor asynchronous processes.
	Logger log.Logger
}

Config is the configuration for the EventStore.

type EventStore

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

EventStore listens for event messages using the transport and stores them for later use.

func New

func New(cfg Config) (*EventStore, error)

New returns a new instance of the EventStore struct.

func (*EventStore) Events

func (e *EventStore) Events(ctx context.Context, typ string, idx []byte) ([]*messages.Event, error)

Events returns events for the given type and index. The method is thread-safe.

func (*EventStore) Start

func (e *EventStore) Start(ctx context.Context) error

func (*EventStore) Wait

func (e *EventStore) Wait() chan error

Wait waits until the context is canceled or until an error occurs.

type MemoryStorage added in v0.6.0

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

MemoryStorage provides storage mechanism for store.EventStore. It stores events in a local memory.

func NewMemoryStorage added in v0.6.0

func NewMemoryStorage(ttl time.Duration) *MemoryStorage

NewMemoryStorage returns a new instance of MemoryStorage. The ttl argument specifies how long messages should be kept in storage.

func (*MemoryStorage) Add added in v0.6.0

func (m *MemoryStorage) Add(_ context.Context, author []byte, evt *messages.Event) (bool, error)

Add implements the store.Storage interface.

func (*MemoryStorage) Get added in v0.6.0

func (m *MemoryStorage) Get(_ context.Context, typ string, idx []byte) ([]*messages.Event, error)

Get implements the store.Storage interface.

type Storage

type Storage interface {
	// Add adds an event to the store. If the event already exists, it will be
	// updated if the MessageDate is newer. The first argument is true if the
	// event was added, false if it was replaced. The method is thread-safe.
	Add(ctx context.Context, author []byte, evt *messages.Event) (bool, error)
	// Get returns messages form the store for the given type and index. If the
	// message does not exist, nil will be returned. The method is thread-safe.
	Get(ctx context.Context, typ string, idx []byte) ([]*messages.Event, error)
}

Storage provides an interface to the event storage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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