bus

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	// Run is a task which maintains and closes connection
	Run(publishCh <-chan interface{}) parallel.Task

	// Subscribe returns task subscribing to the type-specific topic, receiving messages from there and distributing them between receiving channels
	Subscribe(ctx context.Context, templatePtr Entity, recvChs []chan<- interface{}) parallel.Task
}

Connection is an interface of event broker client

func NewNATSConnection

func NewNATSConnection(config infra.Config, dispatcherF DispatcherFactory) Connection

NewNATSConnection creates new NATS connection

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, msg []byte)
}

Dispatcher decodes, validates and sends message to local shard

type DispatcherFactory

type DispatcherFactory interface {
	Create(templatePtr Entity, recvChs []chan<- interface{}, log *zap.Logger) Dispatcher
}

DispatcherFactory creates dispatchers

func NewDispatcherFactory

func NewDispatcherFactory(config infra.Config, shardIDGen sharding.IDGenerator) DispatcherFactory

NewDispatcherFactory creates new dispatcher factory

type Entity

type Entity interface {
	// ShardSeed generates a seed used to compute shard ID
	ShardSeed() []byte

	// Validate validates if message contains valid data
	Validate() error
}

Entity is implemented by structures which may be received from event bus

Jump to

Keyboard shortcuts

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