event

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MissingTypeError = fmt.Errorf("event type is missing")

Functions

This section is empty.

Types

type Builder

type Builder[DT, MT any] interface {
	WithId(id uuid.UUID) builder[DT, MT]
	WithType(t Type) builder[DT, MT]
	WithData(data DT) builder[DT, MT]
	WithMetadata(data Metadata[MT]) builder[DT, MT]
	Build() (ev Event[DT, MT], err error)
}

func NewBuilder

func NewBuilder[DT, MT any]() Builder[DT, MT]

type Event

type Event[DT, MT any] struct {
	Id       uuid.UUID    `json:"id"`
	Type     Type         `json:"type"`
	Data     DT           `json:"data"`
	Metadata Metadata[MT] `json:"metadata"`

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

type Metadata

type Metadata[MT any] 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
	Event     MT        `json:"event"`
	Created   time.Time `json:"created"`
}

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

Jump to

Keyboard shortcuts

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