events

package
v0.365.15 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEvents

func GenerateEvents(ctx context.Context) error

Gather, create and send events which have occurred within the scope of this context.

func HasEventHandler

func HasEventHandler(ctx context.Context) bool

func WithEventHandler

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

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) 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 data relevant to this target type.
	Data map[string]any `json:"data"`
}

Jump to

Keyboard shortcuts

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