event

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidTypeError = fmt.Errorf("event type is invalid")

Functions

This section is empty.

Types

type Builder

type Builder interface {
	WithType(t Type) builder
	WithData(data []byte) builder
	WithMetadata(data Metadata) builder
	BuildRead() (ev ByteReadEvent, err error)
	BuildStore() (ev ByteWriteEvent, err error)
}

func NewBuilder

func NewBuilder() Builder

type ByteEvent added in v0.13.0

type ByteEvent Event[[]byte]

type ByteReadEvent added in v0.13.0

type ByteReadEvent ReadEvent[[]byte]

type ByteWriteEvent added in v0.13.0

type ByteWriteEvent WriteEvent[[]byte]

type Event

type Event[T any] struct {
	Type     Type     `json:"type"`
	Data     T        `json:"data"`
	Metadata Metadata `json:"metadata"`
}

type Metadata

type Metadata struct {
	Stream    string         `json:"stream"`
	EventType Type           `json:"event_type"`
	Version   string         `json:"version"`
	DataType  string         `json:"data_type"`
	Key       string         `json:"key"` //Strictly used for things like getting the cryptoKey
	Extra     map[string]any `json:"extra"`
	Created   time.Time      `json:"created"`
}

type ReadEvent added in v0.11.0

type ReadEvent[T any] struct {
	Event[T]

	Position uint64    `json:"position"`
	Created  time.Time `json:"created"`
}

type ReadEventWAcc added in v0.13.0

type ReadEventWAcc[T any] struct {
	ReadEvent[T]

	Acc func()
	CTX context.Context
}

type Type

type Type string
const (
	Create  Type = "create"
	Update  Type = "update"
	Delete  Type = "delete"
	Invalid Type = "invalid"
)

func AllTypes

func AllTypes() []Type

func TypeFromString

func TypeFromString(s string) Type

type WriteEvent added in v0.13.0

type WriteEvent[T any] struct {
	Event[T]

	Status chan<- WriteStatus
}

type WriteEventReadStatus added in v0.13.0

type WriteEventReadStatus[T any] interface {
	Event() Event[T]
	Done() <-chan struct{}
	Close()
}

func NewWriteEvent added in v0.13.0

func NewWriteEvent[T any](e Event[T]) WriteEventReadStatus[T]

type WriteStatus added in v0.13.0

type WriteStatus struct {
	Error    error
	Position uint64
	Time     time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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