ehclient

package
v0.2.1-0...-bdf8d29 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Event Horizon client

Index

Constants

This section is empty.

Variables

View Source
var MetaTypes = ehevent.Allocators{
	"ChildStreamCreated": func() ehevent.Event { return &ChildStreamCreated{} },
	"StreamStarted":      func() ehevent.Event { return &StreamStarted{} },
}

please have a very good reason if you use this from outside of this package

Functions

func Bootstrap

func Bootstrap(ctx context.Context, e *Client) error

creates the root ("/") stream and "/_sub" sub-stream

Types

type AppendResult

type AppendResult struct {
	Cursor Cursor
}

type ChildStreamCreated

type ChildStreamCreated struct {
	Stream string
	// contains filtered or unexported fields
}

func NewChildStreamCreated

func NewChildStreamCreated(stream string, meta ehevent.EventMeta) *ChildStreamCreated

func (*ChildStreamCreated) Meta

func (*ChildStreamCreated) MetaType

func (e *ChildStreamCreated) MetaType() string

type Client

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

func New

func New(opts DynamoDbOptions) *Client

func (*Client) Append

func (e *Client) Append(ctx context.Context, stream string, events []string) (*AppendResult, error)

func (*Client) AppendAfter

func (e *Client) AppendAfter(ctx context.Context, after Cursor, events []string) (*AppendResult, error)

NOTE: be very sure that stream exists, since it is not validated (only happens if malicious Cursor provided) NOTE: be sure that you don't set version into the future, since that will leave a gap NOTE: returned error is *ErrOptimisticLockingFailed if stream had writes

func (*Client) CreateStream

func (e *Client) CreateStream(ctx context.Context, parent string, name string) error

func (*Client) Read

func (e *Client) Read(ctx context.Context, lastKnown Cursor) (*ReadResult, error)

"lastKnown" is exclusive (i.e. the record pointed by it will not be returned)

type Cursor

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

func At

func At(stream string, version int64) Cursor

func Beginning

func Beginning(stream string) Cursor

func (*Cursor) AtBeginning

func (c *Cursor) AtBeginning() bool

func (*Cursor) Equal

func (c *Cursor) Equal(other Cursor) bool

func (*Cursor) Less

func (c *Cursor) Less(other Cursor) bool

func (*Cursor) Next

func (c *Cursor) Next() Cursor

func (*Cursor) Serialize

func (c *Cursor) Serialize() string

func (*Cursor) Stream

func (c *Cursor) Stream() string

func (*Cursor) Version

func (c *Cursor) Version() int64

type DynamoDbOptions

type DynamoDbOptions struct {
	AccessKeyId     string
	AccessKeySecret string
	RegionId        string
	TableName       string
}

type ErrOptimisticLockingFailed

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

func NewErrOptimisticLockingFailed

func NewErrOptimisticLockingFailed(err error) *ErrOptimisticLockingFailed

needed for testing from outside of this package

type LogEntry

type LogEntry struct {
	Stream    string   `json:"s"` // stream + version form the composite key
	Version   int64    `json:"v"`
	MetaEvent *string  `json:"meta_event"` // StreamStarted | ChildStreamCreated created | ...
	Events    []string `json:"e"`
}

Raw entry from DynamoDB - can contain 0-n events. commit all events in a single transaction. - might contain a single meta event - why most common attribute names shortened? DynamoDB charges for each byte in item attribute names.. - we have JSON marshalling defined but please consider it DynamoDB internal implementation

type ReadResult

type ReadResult struct {
	Entries   []LogEntry
	LastEntry Cursor // Entries[last].Version (use only if you handled all entries) or if no entries, the "after" in Read()
	More      bool   // whether there is more data to fetch
}

type Reader

type Reader interface {
	Read(ctx context.Context, lastKnown Cursor) (*ReadResult, error)
}

interface for reading log entries from a stream

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

type StreamStarted

type StreamStarted struct {
	Parent string
	// contains filtered or unexported fields
}

func NewStreamStarted

func NewStreamStarted(parent string, meta ehevent.EventMeta) *StreamStarted

func (*StreamStarted) Meta

func (e *StreamStarted) Meta() *ehevent.EventMeta

func (*StreamStarted) MetaType

func (e *StreamStarted) MetaType() string

type Writer

type Writer interface {
	Append(ctx context.Context, stream string, events []string) (*AppendResult, error)
	// used for transactional writes
	// returns *ErrOptimisticLockingFailed if stream had writes after you read it
	AppendAfter(ctx context.Context, after Cursor, events []string) (*AppendResult, error)
}

interface for appending log entries to a stream

Jump to

Keyboard shortcuts

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