events

package
v0.385.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Created = "created"
	Updated = "updated"
	Deleted = "deleted"
)

Event names

Variables

This section is empty.

Functions

func HasEventHandler

func HasEventHandler(ctx context.Context) bool

func SendEvents added in v0.368.0

func SendEvents(ctx context.Context, schema *proto.Schema) error

SendEvents will gather, create and send events which have occurred within the scope of this context. It achieves this by inspecting the keel_audit table for rows which must be generated into events, updates the event_processed_at field on these rows, and then calls the event handler for each event.

func WithEventHandler

func WithEventHandler(ctx context.Context, handler EventHandler) (context.Context, error)

Types

type Event

type Event struct {
	// The name of the event, e.g. member.created.
	EventName string `json:"eventName"`
	// The time at which the event was created.
	OccurredAt time.Time `json:"occurredAt"`
	// The identity that resulted in the triggered events.
	IdentityId string `json:"identityId,omitempty"`
	// The target impacted by this event.
	Target *EventTarget `json:"target"`
}

type EventHandler

type EventHandler func(ctx context.Context, subscriber string, event *Event, traceparent string) error

The event handler function to be executed for each subscriber event generated.

func GetEventHandler

func GetEventHandler(ctx context.Context) (EventHandler, error)

type EventTarget

type EventTarget struct {
	// The id of the target, if applicable.
	Id string `json:"id"`
	// The type of event target, e.g. Employee
	Type string `json:"type"`
	// The model data at the time of the event.
	Data map[string]any `json:"data"`
	// The previous state of the model data before the event.
	PreviousData map[string]any `json:"previousData"`
}

Jump to

Keyboard shortcuts

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