event

package
v0.7.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidType = 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 WriteEvent[[]byte], err error)
}

func NewBuilder

func NewBuilder() Builder

type ByteEvent

type ByteEvent Event[[]byte]

type ByteReadEvent

type ByteReadEvent ReadEvent[[]byte]

type ByteWriteEvent

type ByteWriteEvent WriteEvent[[]byte]

type Event

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

type Metadata

type Metadata struct {
	Created   time.Time                           `json:"created"`
	Extra     map[bcts.TinyString]bcts.SmallBytes `json:"extra"`
	Stream    string                              `json:"stream"`
	EventType Type                                `json:"event_type"`
	Version   string                              `json:"version"`
	DataType  string                              `json:"data_type"`
	Key       string                              `json:"key"`
}

func (*Metadata) ReadBytes added in v0.7.5

func (m *Metadata) ReadBytes(r io.Reader) (err error)

func (Metadata) WriteBytes added in v0.7.5

func (m Metadata) WriteBytes(w *bufio.Writer) (err error)

type ReadEvent

type ReadEvent[T any] struct {
	Created time.Time `json:"created"`
	Event[T]
	Position uint64 `json:"position"`
}

type ReadEventWAcc

type ReadEventWAcc[T any] struct {
	CTX context.Context
	Acc func()
	ReadEvent[T]
}

type Type

type Type string
const (
	Created Type = "created"
	Updated Type = "updated"
	Deleted Type = "deleted"
	Invalid Type = "invalid"
)

func AllTypes

func AllTypes() []Type

func TypeFromString

func TypeFromString(s string) Type

type WriteEvent

type WriteEvent[T any] struct {
	// contains filtered or unexported fields
}

func (*WriteEvent[T]) Close

func (e *WriteEvent[T]) Close(status store.WriteStatus)

func (*WriteEvent[T]) Done

func (e *WriteEvent[T]) Done() <-chan store.WriteStatus

func (*WriteEvent[T]) Event

func (e *WriteEvent[T]) Event() *Event[T]

func (*WriteEvent[T]) StatusChan

func (e *WriteEvent[T]) StatusChan() chan store.WriteStatus

func (*WriteEvent[T]) Store

func (e *WriteEvent[T]) Store() *store.WriteEvent

type WriteEventReadStatus

type WriteEventReadStatus[T any] interface {
	Event() *Event[T]
	Done() <-chan store.WriteStatus
	Close(store.WriteStatus)
	Store() *store.WriteEvent
	StatusChan() chan store.WriteStatus
}

func Map

func Map[OT, NT any](e WriteEventReadStatus[OT], f func(OT) NT) WriteEventReadStatus[NT]

func NewWriteEvent

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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