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
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 ¶
IsRunning returns `true` if multiplexer is running pumping events from the inputs to the output.
func (*T) IsSafe2Stop ¶ added in v0.14.0
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) WireUp ¶
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.