event

package module
v0.0.0-...-77d04a8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	*lifecycle.Lifecycle
	Config
	// contains filtered or unexported fields
}

Bus implements a publisher/subscriber using Go channels. This implementation works only on a single node, i.e. handlers are not distributed. In order to distribute the load across a cluster, a persistent message queue (such as RabbitMQ or Kafka) should instead be used.

func Initialize

func Initialize(cfg Config) (*Bus, error)

Initialize event.

func NewEventBus

func NewEventBus(cfg Config) *Bus

NewEventBus returns in-memory event bus.

func (*Bus) Close

func (b *Bus) Close() error

Close closes all resources.

func (*Bus) IsConnected

func (b *Bus) IsConnected() bool

IsConnected return true is connected.

func (*Bus) Publish

func (b *Bus) Publish(_ context.Context, topic string, messages ...*spi.Event) error

Publish publishes the given messages to the given topic. This function returns immediately after sending the messages to the Go channel(s), although it will block if the concurrency limit (defined by Config.Concurrency) has been reached.

func (*Bus) Subscribe

func (b *Bus) Subscribe(_ context.Context, topic string) (<-chan *spi.Event, error)

Subscribe subscribes to a topic and returns the Go channel over which messages are sent. The returned channel will be closed when Close() is called on this struct.

type Config

type Config struct {
	TLSConfig      *tls.Config
	CMD            *cobra.Command
	CSLVCStore     credentialstatus.CSLVCStore
	ProfileService profileService
	KMSRegistry    kmsRegistry
	Crypto         vcCrypto
	Tracer         trace.Tracer
	IsTraceEnabled bool
	DocumentLoader ld.DocumentLoader
}

Config holds the configuration for the publisher/subscriber.

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

func NewEventPublisher

func NewEventPublisher(pub eventPublisher) *Publisher

NewEventPublisher creates event publisher.

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, topic string, events ...*spi.Event) error

type Subscriber

type Subscriber struct {
	*lifecycle.Lifecycle
	// contains filtered or unexported fields
}

Subscriber implements an event subscriber.

func NewEventSubscriber

func NewEventSubscriber(sub eventSubscriber, topic string, handler eventHandler) (*Subscriber, error)

NewEventSubscriber returns a new subscriber.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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