bus

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StreamName       = "events"
	BroadcastSubject = "broadcast"
	QueueSubject     = "queue"
)
View Source
const (
	CreateConnection = "CreateConnection"
	UpdateConnection = "UpdateConnection"
	DeleteConnection = "DeleteConnection"

	CreateRelay = "CreateRelay"
	UpdateRelay = "UpdateRelay"
	DeleteRelay = "DeleteRelay"
	StopRelay   = "StopRelay"
	ResumeRelay = "ResumeRelay"

	CreateTunnel = "CreateTunnel"
	UpdateTunnel = "UpdateTunnel"
	DeleteTunnel = "DeleteTunnel"
	StopTunnel   = "StopTunnel"
	ResumeTunnel = "ResumeTunnel"

	UpdateConfig = "UpdateConfig"
)

Variables

View Source
var (
	ConsumersNotRunning     = errors.New("nothing to stop - consumers not running")
	ConsumersAlreadyRunning = errors.New("cannot start - consumers already running")
)

Functions

This section is empty.

Types

type Action

type Action string

type Bus

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

func New

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

func (*Bus) PublishCreateConnection

func (b *Bus) PublishCreateConnection(ctx context.Context, conn *opts.ConnectionOptions) error

PublishCreateConnection publishes a CreateConnection message, which other plumber instances will receive and add the connection to their local in-memory maps

func (*Bus) PublishCreateRelay

func (b *Bus) PublishCreateRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishCreateRelay publishes a CreateRelay message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Bus) PublishCreateTunnel added in v1.4.0

func (b *Bus) PublishCreateTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error

PublishCreateTunnel publishes a CreateTunnel message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Bus) PublishDeleteConnection

func (b *Bus) PublishDeleteConnection(ctx context.Context, conn *opts.ConnectionOptions) error

PublishDeleteConnection publishes a DeleteConnection message, which other plumber instances will receive and delete from their local in-memory maps

func (*Bus) PublishDeleteRelay

func (b *Bus) PublishDeleteRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishDeleteRelay publishes a DeleteRelay message, which other plumber instances will receive and delete from their local in-memory maps

func (*Bus) PublishDeleteTunnel added in v1.4.0

func (b *Bus) PublishDeleteTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error

PublishDeleteTunnel publishes a DeleteTunnel message, which other plumber instances will receive and delete from their local in-memory maps

func (*Bus) PublishResumeRelay

func (b *Bus) PublishResumeRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishResumeRelay broadcasts a ResumeRelay message which will cause all plumber instances to start a stopped relay and add it to their in-memory cache.

func (*Bus) PublishResumeTunnel added in v1.4.0

func (b *Bus) PublishResumeTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error

PublishResumeTunnel broadcasts a ResumeTunnel message which will cause all plumber instances to start a stopped relay and add it to their in-memory cache.

func (*Bus) PublishStopRelay

func (b *Bus) PublishStopRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishStopRelay broadcasts a StopRelay message which will cause all plumber instances to stop the relay and remove it from their in-memory cache.

func (*Bus) PublishStopTunnel added in v1.4.0

func (b *Bus) PublishStopTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error

PublishStopTunnel broadcasts a StopTunnel message which will cause all plumber instances to stop the relay and remove it from their in-memory cache.

func (*Bus) PublishUpdateConnection

func (b *Bus) PublishUpdateConnection(ctx context.Context, conn *opts.ConnectionOptions) error

PublishUpdateConnection publishes an UpdateConnection message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Bus) PublishUpdateRelay

func (b *Bus) PublishUpdateRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishUpdateRelay publishes an UpdateRelay message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Bus) PublishUpdateTunnel added in v1.4.0

func (b *Bus) PublishUpdateTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error

PublishUpdateTunnel publishes an UpdateTunnel message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Bus) Start

func (b *Bus) Start(serviceCtx context.Context) error

func (*Bus) Stop

func (b *Bus) Stop() error

type Config

type Config struct {
	ServerOptions    *opts.ServerOptions
	PersistentConfig *config.Config // Consumers will need this to update their local config
	Actions          actions.IActions
}

type IBus

type IBus interface {
	// Start starts up the broadcast and queue consumers
	Start(serviceCtx context.Context) error

	// Stop stops the broadcast and queue consumers
	Stop() error

	PublishCreateConnection(ctx context.Context, conn *opts.ConnectionOptions) error
	PublishUpdateConnection(ctx context.Context, conn *opts.ConnectionOptions) error
	PublishDeleteConnection(ctx context.Context, conn *opts.ConnectionOptions) error

	PublishCreateRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishUpdateRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishDeleteRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishStopRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishResumeRelay(ctx context.Context, relay *opts.RelayOptions) error

	PublishCreateTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error
	PublishUpdateTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error
	PublishStopTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error
	PublishResumeTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error
	PublishDeleteTunnel(ctx context.Context, tunnelOptions *opts.TunnelOptions) error
}

type Message

type Message struct {
	Action    Action
	Data      []byte // <- consumer decides what's in here based on action
	Metadata  map[string]string
	EmittedBy string
	EmittedAt time.Time // UTC
}

func (*Message) Validate

func (m *Message) Validate() error

TODO: implement, this isn't being used anywhere at the moment

type NoOpBus

type NoOpBus struct{}

NoOpBus is a bus that does nothing

func (NoOpBus) PublishCreateConnection

func (n NoOpBus) PublishCreateConnection(_ context.Context, _ *opts.ConnectionOptions) error

func (NoOpBus) PublishCreateRelay

func (n NoOpBus) PublishCreateRelay(_ context.Context, _ *opts.RelayOptions) error

func (NoOpBus) PublishCreateTunnel added in v1.4.0

func (n NoOpBus) PublishCreateTunnel(_ context.Context, _ *opts.TunnelOptions) error

func (NoOpBus) PublishDeleteConnection

func (n NoOpBus) PublishDeleteConnection(_ context.Context, _ *opts.ConnectionOptions) error

func (NoOpBus) PublishDeleteRelay

func (n NoOpBus) PublishDeleteRelay(_ context.Context, _ *opts.RelayOptions) error

func (NoOpBus) PublishDeleteTunnel added in v1.4.0

func (n NoOpBus) PublishDeleteTunnel(_ context.Context, _ *opts.TunnelOptions) error

func (NoOpBus) PublishResumeRelay

func (n NoOpBus) PublishResumeRelay(_ context.Context, _ *opts.RelayOptions) error

func (NoOpBus) PublishResumeTunnel added in v1.4.0

func (n NoOpBus) PublishResumeTunnel(_ context.Context, _ *opts.TunnelOptions) error

func (NoOpBus) PublishStopRelay

func (n NoOpBus) PublishStopRelay(_ context.Context, _ *opts.RelayOptions) error

func (NoOpBus) PublishStopTunnel added in v1.4.0

func (n NoOpBus) PublishStopTunnel(_ context.Context, _ *opts.TunnelOptions) error

func (NoOpBus) PublishUpdateConnection

func (n NoOpBus) PublishUpdateConnection(_ context.Context, _ *opts.ConnectionOptions) error

func (NoOpBus) PublishUpdateRelay

func (n NoOpBus) PublishUpdateRelay(_ context.Context, _ *opts.RelayOptions) error

func (NoOpBus) PublishUpdateTunnel added in v1.4.0

func (n NoOpBus) PublishUpdateTunnel(_ context.Context, _ *opts.TunnelOptions) error

func (NoOpBus) Start

func (n NoOpBus) Start(_ context.Context) error

func (NoOpBus) Stop

func (n NoOpBus) Stop() error

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