Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Append(ctx context.Context, event EventData) (versionPrevious Version, version Version, tm time.Time, err error)
- func (c *Client) AppendCheck(ctx context.Context, assumedVersion Version, event EventData) (version Version, tm time.Time, err error)
- func (c *Client) AppendCheckMulti(ctx context.Context, assumedVersion Version, events ...EventData) (versionFirst Version, version Version, tm time.Time, err error)
- func (c *Client) AppendMulti(ctx context.Context, events ...EventData) (versionPrevious Version, versionFirst Version, version Version, tm time.Time, ...)
- func (c *Client) Listen(ctx context.Context, onUpdate func(Version)) error
- func (c *Client) Metadata(ctx context.Context) (map[string]string, error)
- func (c *Client) Scan(ctx context.Context, version Version, reverse bool, skipFirst bool, ...) error
- func (c *Client) TryAppend(ctx context.Context, assumedVersion Version, ...) (versionPrevious Version, version Version, tm time.Time, err error)
- func (c *Client) TryAppendMulti(ctx context.Context, assumedVersion Version, ...) (versionPrevious Version, versionFirst Version, version Version, tm time.Time, ...)
- func (c *Client) Version(ctx context.Context) (Version, error)
- func (c *Client) VersionInitial(ctx context.Context) (Version, error)
- type Event
- type EventData
- type HTTP
- func (c *HTTP) Append(ctx context.Context, event EventData) (versionPrevious Version, version Version, tm time.Time, err error)
- func (c *HTTP) AppendCheck(ctx context.Context, assumedVersion Version, event EventData) (version Version, tm time.Time, err error)
- func (c *HTTP) AppendCheckMulti(ctx context.Context, assumedVersion Version, events ...EventData) (versionFirst Version, version Version, tm time.Time, err error)
- func (c *HTTP) AppendMulti(ctx context.Context, events ...EventData) (versionPrevious Version, versionFirst Version, version Version, tm time.Time, ...)
- func (c *HTTP) GetRetryInterval() time.Duration
- func (c *HTTP) Listen(ctx context.Context, onUpdate func(Version)) error
- func (c *HTTP) Metadata(ctx context.Context) (map[string]string, error)
- func (c *HTTP) Scan(ctx context.Context, version Version, reverse bool, skipFirst bool, ...) error
- func (c *HTTP) SetRetryInterval(d time.Duration)
- func (c *HTTP) Version(ctx context.Context) (version Version, err error)
- func (c *HTTP) VersionInitial(ctx context.Context) (version Version, err error)
- type Inmem
- func (c *Inmem) Append(ctx context.Context, event EventData) (versionPrevious Version, version Version, tm time.Time, err error)
- func (c *Inmem) AppendCheck(ctx context.Context, assumedVersion Version, event EventData) (version Version, tm time.Time, err error)
- func (c *Inmem) AppendCheckMulti(ctx context.Context, assumedVersion Version, events ...EventData) (versionFirst Version, version Version, tm time.Time, err error)
- func (c *Inmem) AppendMulti(ctx context.Context, events ...EventData) (versionPrevious Version, versionFirst Version, version Version, tm time.Time, ...)
- func (c *Inmem) Listen(ctx context.Context, onUpdate func(Version)) error
- func (c *Inmem) Metadata(ctx context.Context) (m map[string]string, err error)
- func (c *Inmem) Scan(ctx context.Context, version Version, reverse bool, skipFirst bool, ...) error
- func (c *Inmem) Version(ctx context.Context) (Version, error)
- func (c *Inmem) VersionInitial(ctx context.Context) (Version, error)
- type Log
- type ReadWriter
- type Reader
- type Version
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( ErrMismatchingVersions = eventlog.ErrMismatchingVersions ErrInvalidPayload = eventlog.ErrInvalidPayload ErrPayloadSizeLimitExceeded = eventlog.ErrPayloadSizeLimitExceeded ErrInvalidVersion = errors.New("invalid version") ErrMalformedVersion = errors.New("malformed version") ErrLabelTooLong = fmt.Errorf( "label must not exceed %d bytes", internal.MaxLabelLen, ) ErrNoEvents = errors.New("no events") )
Error values
var ErrSocketClosed = errors.New("socket closed")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Append ¶
func (c *Client) Append( ctx context.Context, event EventData, ) ( versionPrevious Version, version Version, tm time.Time, err error, )
Append appends a new event onto the log.
func (*Client) AppendCheck ¶
func (c *Client) AppendCheck( ctx context.Context, assumedVersion Version, event EventData, ) ( version Version, tm time.Time, err error, )
AppendCheck appends a new event onto the log if the assumed version matches the latest log version, otherwise the operation is rejected and ErrMismatchingVersions is returned.
func (*Client) AppendCheckMulti ¶
func (c *Client) AppendCheckMulti( ctx context.Context, assumedVersion Version, events ...EventData, ) ( versionFirst Version, version Version, tm time.Time, err error, )
AppendCheckMulti appends one or multiple new events onto the log if the assumed version matches the latest log version, otherwise the operation is rejected and ErrMismatchingVersions is returned.
func (*Client) AppendMulti ¶
func (c *Client) AppendMulti( ctx context.Context, events ...EventData, ) ( versionPrevious Version, versionFirst Version, version Version, tm time.Time, err error, )
AppendMulti appends one or multiple new events onto the log.
func (*Client) Listen ¶
Listen establishes a websocket connection to the server and starts listening for version update notifications calling onUpdate when one is received.
func (*Client) Scan ¶
func (c *Client) Scan( ctx context.Context, version Version, reverse bool, skipFirst bool, fn func(Event) error, ) error
Scan reads events at the given version calling fn for every received event. Scans in reverse if reverse == true. Skips the first Event at version if skipFirst == true.
func (*Client) TryAppend ¶
func (c *Client) TryAppend( ctx context.Context, assumedVersion Version, transaction func() (event EventData, err error), sync func() (Version, error), ) ( versionPrevious Version, version Version, tm time.Time, err error, )
TryAppend keeps executing transaction until either cancelled, succeeded (assumed == latest event log version) or failed due to an error.
func (*Client) TryAppendMulti ¶
func (c *Client) TryAppendMulti( ctx context.Context, assumedVersion Version, transaction func() (events []EventData, err error), sync func() (Version, error), ) ( versionPrevious Version, versionFirst Version, version Version, tm time.Time, err error, )
TryAppendMulti keeps executing transaction until either cancelled, succeeded (assumed == latest event log version) or failed due to an error.
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is an HTTP eventlog read-writer.
func (*HTTP) Append ¶
func (c *HTTP) Append( ctx context.Context, event EventData, ) ( versionPrevious Version, version Version, tm time.Time, err error, )
Append implements Writer.Append.
func (*HTTP) AppendCheck ¶
func (c *HTTP) AppendCheck( ctx context.Context, assumedVersion Version, event EventData, ) ( version Version, tm time.Time, err error, )
AppendCheck implements Writer.AppendCheck.
func (*HTTP) AppendCheckMulti ¶
func (c *HTTP) AppendCheckMulti( ctx context.Context, assumedVersion Version, events ...EventData, ) ( versionFirst Version, version Version, tm time.Time, err error, )
AppendCheckMulti implements Writer.AppendCheckMulti.
func (*HTTP) AppendMulti ¶
func (c *HTTP) AppendMulti( ctx context.Context, events ...EventData, ) ( versionPrevious Version, versionFirst Version, version Version, tm time.Time, err error, )
AppendMulti implements Writer.AppendMulti.
func (*HTTP) GetRetryInterval ¶
GetRetryInterval returns the current retry interval. Returns 0 if automatic retry is disabled.
func (*HTTP) Listen ¶
Listen establishes a websocket connection to the server and starts listening for version update notifications calling onUpdate when one is received.
func (*HTTP) Scan ¶
func (c *HTTP) Scan( ctx context.Context, version Version, reverse bool, skipFirst bool, fn func(Event) error, ) error
Scan implements Reader.Scan.
WARNING: manually cancelable (non-timeout and non-deadline) contexts are not supported.
func (*HTTP) SetRetryInterval ¶
SetRetryInterval enables automatic retries if d > 0, otherwise automatic retry is disabled.
type Inmem ¶
type Inmem struct {
// contains filtered or unexported fields
}
Inmem is an in-memory eventlog connecter.
func (*Inmem) Append ¶
func (c *Inmem) Append(ctx context.Context, event EventData) ( versionPrevious Version, version Version, tm time.Time, err error, )
Append implements Connecter.Append.
func (*Inmem) AppendCheck ¶
func (c *Inmem) AppendCheck( ctx context.Context, assumedVersion Version, event EventData, ) ( version Version, tm time.Time, err error, )
AppendCheck implements Connecter.AppendCheck.
func (*Inmem) AppendCheckMulti ¶
func (c *Inmem) AppendCheckMulti( ctx context.Context, assumedVersion Version, events ...EventData, ) ( versionFirst Version, version Version, tm time.Time, err error, )
AppendCheckMulti implements Connecter.AppendCheckMulti.
func (*Inmem) AppendMulti ¶
func (c *Inmem) AppendMulti(ctx context.Context, events ...EventData) ( versionPrevious Version, versionFirst Version, version Version, tm time.Time, err error, )
AppendMulti implements Connecter.AppendMulti.
func (*Inmem) Scan ¶
func (c *Inmem) Scan( ctx context.Context, version Version, reverse bool, skipFirst bool, fn func(Event) error, ) error
Scan implements Connecter.Scan.
type ReadWriter ¶
ReadWriter is both an eventlog reader and a writer.
type Reader ¶
type Reader interface { Metadata(ctx context.Context) (map[string]string, error) Scan( ctx context.Context, version Version, reverse bool, skipFirst bool, fn func(Event) error, ) error VersionInitial(context.Context) (Version, error) Version(context.Context) (Version, error) Listen(ctx context.Context, onUpdate func(Version)) error }
Reader is an eventlog reader. All reader methods are idempotent.
type Writer ¶
type Writer interface { Append( ctx context.Context, event EventData, ) ( versionPrevious Version, version Version, tm time.Time, err error, ) AppendMulti( ctx context.Context, events ...EventData, ) ( versionPrevious Version, versionFirst Version, version Version, tm time.Time, err error, ) AppendCheck( ctx context.Context, assumedVersion Version, event EventData, ) ( version Version, tm time.Time, err error, ) AppendCheckMulti( ctx context.Context, assumedVersion Version, eventsEncoded ...EventData, ) ( versionFirst Version, version Version, tm time.Time, err error, ) }
Writer is an eventlog writer.