event

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 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[bcts.Bytes, *bcts.Bytes], err error)
}

func NewBuilder

func NewBuilder() Builder

type ByteEvent

type ByteEvent Event[bcts.Bytes, *bcts.Bytes]

type ByteReadEvent

type ByteReadEvent ReadEvent[bcts.Bytes, *bcts.Bytes]

type ByteWriteEvent

type ByteWriteEvent WriteEvent[bcts.Bytes, *bcts.Bytes]

type Event

type Event[BT any, T bcts.ReadWriter[BT]] struct {
	Metadata Metadata `json:"metadata"`
	Data     T        `json:"data"`
	Type     Type     `json:"type"`
}

func (*Event[BT, T]) ReadBytes added in v0.7.7

func (e *Event[BT, T]) ReadBytes(r io.Reader) (err error)

func (Event[BT, T]) WriteBytes added in v0.7.7

func (e Event[BT, T]) WriteBytes(w io.Writer) (err error)

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 io.Writer) (err error)

type ReadEvent

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

func (*ReadEvent[BT, T]) ReadBytes added in v0.7.7

func (e *ReadEvent[BT, T]) ReadBytes(r io.Reader) (err error)

func (ReadEvent[BT, T]) WriteBytes added in v0.7.7

func (e ReadEvent[BT, T]) WriteBytes(w io.Writer) (err error)

type ReadEventWAcc

type ReadEventWAcc[BT any, T bcts.ReadWriter[BT]] struct {
	CTX context.Context
	Acc func()
	ReadEvent[BT, 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

func (*Type) ReadBytes added in v0.7.7

func (t *Type) ReadBytes(r io.Reader) (err error)

func (Type) WriteBytes added in v0.7.7

func (t Type) WriteBytes(w io.Writer) (err error)

type WriteEvent

type WriteEvent[BT any, T bcts.ReadWriter[BT]] struct {
	// contains filtered or unexported fields
}

func (*WriteEvent[BT, T]) Close

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

func (*WriteEvent[BT, T]) Done

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

func (*WriteEvent[BT, T]) Event

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

func (*WriteEvent[BT, T]) StatusChan

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

func (*WriteEvent[BT, T]) Store

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

type WriteEventReadStatus

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

func Map

func Map[OT, NT any, OOT bcts.ReadWriter[OT], NNT bcts.ReadWriter[NT]](
	e WriteEventReadStatus[OT, OOT],
	f func(OOT) NNT,
) WriteEventReadStatus[NT, NNT]

func NewWriteEvent

func NewWriteEvent[BT any, T bcts.ReadWriter[BT]](
	e Event[BT, T],
) WriteEventReadStatus[BT, T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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