eventbus

package
v0.0.0-...-087ca59 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandlerOption

func NewHandlerOption[T any](isSync bool, handler func(ctx context.Context, msg *T) error) pubsub.HandlerOptions

func Publish

func Publish[T any](ctx context.Context, obj *T)

func PublishJSON

func PublishJSON(ctx context.Context, topic string, obj interface{})

func SetClient

func SetClient(serviceName string, provider pubsub.Provider)

func Subscribe

func Subscribe[T any](handler func(ctx context.Context, msg *T) error)

func SubscribeSync

func SubscribeSync[T any](handler func(ctx context.Context, msg *T) error)

SubscribeSync is a synchronous version of Subscribe.

Types

type EntityCreatedEvent

type EntityCreatedEvent[T any] struct {
	Entity *T `json:"entity"`
}

func Created

func Created[T any](entity *T) *EntityCreatedEvent[T]

type EntityDeletedEvent

type EntityDeletedEvent[T any] struct {
	ID     string `json:"id"`
	Entity *T     `json:"entity"`
}

func Deleted

func Deleted[T any](entity *T) *EntityDeletedEvent[T]

type EntityUpdatedEvent

type EntityUpdatedEvent[T any] struct {
	Entity *T `json:"entity"`
}

func Updated

func Updated[T any](entity *T) *EntityUpdatedEvent[T]

type MemoryProvider

type MemoryProvider struct {
	ErrorHandler func(ctx context.Context, msg *pubsub.Msg, err error)
	// contains filtered or unexported fields
}

func NewMemoryProvider

func NewMemoryProvider() *MemoryProvider

func (*MemoryProvider) Publish

func (mp *MemoryProvider) Publish(ctx context.Context, topic string, m *pubsub.Msg) error

func (*MemoryProvider) Shutdown

func (mp *MemoryProvider) Shutdown()

func (*MemoryProvider) Subscribe

func (mp *MemoryProvider) Subscribe(opts pubsub.HandlerOptions, h pubsub.MsgHandler)

Jump to

Keyboard shortcuts

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