multiplexer

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type In

type In interface {
	// Messages returns a channel that multiplexer receives messages from.
	// Read messages should NOT be considered as consumed by the input.
	Messages() <-chan consumer.Message

	// IsSafe2Stop returns true if stopping the input now will cause neither
	// loss nor duplication of messages for the clients, false otherwise.
	IsSafe2Stop() bool

	// Stop signals the input to stop and blocks waiting for its goroutines to
	// complete.
	Stop()
}

In defines an interface of a multiplexer input.

type Out

type Out interface {
	// Messages returns channel that multiplexer sends messages to.
	Messages() chan<- consumer.Message
}

Out defines an interface of multiplexer output.

type SpawnInFn added in v0.13.0

type SpawnInFn func(partition int32) In

SpawnInFn is a function type that is used by multiplexer to spawn inputs for assigned partitions during rewiring.

type T

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

T fetches messages from inputs and multiplexes them to the output, giving preferences to inputs with higher lag. Multiplexer assumes ownership over inputs in the sense that it decides when an new input instance needs to be started, or the old one stopped.

func New

func New(parentActDesc *actor.Descriptor, spawnInFn SpawnInFn) *T

New creates a new multiplexer instance.

func (*T) IsRunning

func (m *T) IsRunning() bool

IsRunning returns `true` if multiplexer is running pumping events from the inputs to the output.

func (*T) IsSafe2Stop added in v0.14.0

func (m *T) IsSafe2Stop() bool

IsSafe2Stop returns true if it is safe to stop all of the multiplexer inputs. If at least one of them is not safe to stop then false is returned.

func (*T) Stop

func (m *T) Stop()

Stop synchronously stops the multiplexer.

func (*T) WireUp

func (m *T) WireUp(output Out, assigned []int32)

WireUp ensures that assigned inputs are spawned and multiplexed to the specified output. It stops inputs for partitions that are no longer assigned, spawns inputs for newly assigned partitions, and restarts the multiplexer, if either output or any of inputs has changed.

The multiplexer may be stopped if either output or all inputs are removed.

WARNING: do not ever pass (*T)(nil) in output, that will cause panic.

Jump to

Keyboard shortcuts

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