eventbus

package
v0.0.0-...-8546a7f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 9 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 PublishLocal

func PublishLocal[T any](ctx context.Context, eventData T) error

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 EntityCreatingEvent

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

func Creating

func Creating[T any](entity *T) *EntityCreatingEvent[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 EntityUpdatingEvent

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

func Updating

func Updating[T any](entity *T) *EntityUpdatingEvent[T]

type LocalEventHandler

type LocalEventHandler[T any] interface {
	HandleEvent(ctx context.Context, eventData T) error
}

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