events

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package events provides an event log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction string

Direction is ascending or descending.

const (
	// Ascending direction.
	Ascending Direction = "asc"
	// Descending direction.
	Descending Direction = "desc"
)

type Event

type Event struct {
	// Data for event.
	Data []byte `json:"data" msgpack:"dat" firestore:"data"`

	// Index for event (read only).
	Index int64 `json:"idx" msgpack:"idx" firestore:"idx"`
	// Timestamp (read only). The time at which the event was created.
	// Firestore sets this to the document create time.
	Timestamp int64 `json:"ts" msgpack:"ts" firestore:"-"`
}

Event in an event log. If this format changes, you should also change in firestore and other backends that don't directly use this struct on set.

type Events

type Events interface {
	// EventsAdd appends an event.
	EventsAdd(ctx context.Context, path string, data [][]byte) ([]*Event, error)

	// Events from log.
	Events(ctx context.Context, path string, opt ...Option) (Iterator, error)

	// EventsDelete deletes all events at path.
	EventsDelete(ctx context.Context, path string) (bool, error)
}

Events describes an append only event log.

type Iterator

type Iterator interface {
	// Next document, or nil.
	Next() (*Event, error)
	// Release resources associated with the iterator.
	Release()
}

Iterator is an iterator for Event's.

func NewIterator

func NewIterator(events []*Event) Iterator

NewIterator returns an iterator for a Event slice.

type Option

type Option func(*Options)

Option ...

func Index

func Index(i int64) Option

Index option.

func Limit

func Limit(l int64) Option

Limit option.

func WithDirection

func WithDirection(d Direction) Option

WithDirection option.

type Options

type Options struct {
	// Index to start at.
	Index int64
	// Limit is number of documents (max) to return.
	Limit int64
	// Direction to list.
	Direction Direction
}

Options ...

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions parses Options.

Jump to

Keyboard shortcuts

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