event

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfSync = errors.New("out of sync with changelog. invalidate caches please.")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Sequence  int64
	RowUpdate RowUpdate
}

Event is the type that the Iterator produces

type FilteredIterator added in v0.0.8

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

func NewFilteredIterator added in v0.0.8

func NewFilteredIterator(ctx context.Context, changelogPath, family, table string, opts ...IteratorOpt) (*FilteredIterator, error)

NewFilteredIterator returns a new iterator that looks for changes to the specified family and table in the background and then exposes those changes through the Next method. Make sure to Close() the iterator when you are done using it.

If ErrOutOfSync is returned, that means that the iterator likely could not keep up with the changelog. Please invalidate any caches dependent on this iterator.

If a different error is returned, it's not really known at this time the best way to deal with it. It's possible that it could be a change in the changelog json schema, or something more temporary. Best response for now will be to log and instrument the error, and then just invalidate the cache the same way you would with ErrOutOfSync. As time goes on, we'll know a little bit better how to operate this under real-world conditions.

func (*FilteredIterator) Close added in v0.0.8

func (i *FilteredIterator) Close() error

func (*FilteredIterator) Next added in v0.0.8

func (i *FilteredIterator) Next(ctx context.Context) (event Event, err error)

Next blocks and returns the next event that matches the specified family and table

type Iterator

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

func NewIterator

func NewIterator(ctx context.Context, changelogPath string, opts ...IteratorOpt) (*Iterator, error)

NewIterator returns a new iterator that looks for changes in the background and then exposes those changes through the Next method. Make sure to Close() the iterator when you are done using it.

If ErrOutOfSync is returned, that means that the iterator likely could not keep up with the changelog. Please invalidate any caches dependent on this iterator.

If a different error is returned, it's not really known at this time the best way to deal with it. It's possible that it could be a change in the changelog json schema, or something more temporary. Best response for now will be to log and instrument the error, and then just invalidate the cache the same way you would with ErrOutOfSync. As time goes on, we'll know a little bit better how to operate this under real-world conditions.

func (*Iterator) Close

func (i *Iterator) Close() error

func (*Iterator) Next

func (i *Iterator) Next(ctx context.Context) (event Event, err error)

Next blocks and returns the next event

type IteratorOpt

type IteratorOpt func(i *Iterator)

type Key

type Key struct {
	Name  string      `json:"name"`
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

Key represents a single primary key column value and metadata

type RowUpdate

type RowUpdate struct {
	FamilyName string `json:"family"`
	TableName  string `json:"table"`
	Keys       []Key  `json:"keys"`
}

RowUpdate represents a single row update

Jump to

Keyboard shortcuts

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