Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultBus global Bus instance used by both Writer and Reader if passed Bus instance was nil. DefaultBus *Bus // DefaultBusConfig global Bus instance configuration used by both Writer and Reader if passed Bus instance was nil. DefaultBusConfig Config )
Functions ¶
func Publish ¶
Publish sends a message to one or many readers subscribed to msg.StreamName (aka. fan-out) in a fire-and-forget way meaning the internal writer only cares about writing to the queue whereas subscribers are independent processes.
This routine will fail if Bus is shut down.
func Shutdown ¶
func Shutdown()
Shutdown disposes allocated resources and signals internal processes for a graceful shutdown.
This operation might block I/O as it waits for in-flight reader processes to finish -either by success or timeout-.
func Start ¶
func Start()
Start spins up the Bus readers, blocking the I/O until Bus.Shutdown is called.
func Subscribe ¶
func Subscribe(stream string, handler streams.ReaderHandleFunc)
Subscribe appends a reader handler to a stream.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus Go channel-backed concurrent-safe messaging bus which implements fan-out messaging pattern.
Zero-value IS NOT ready to use, please call NewBus routine instead.
func (*Bus) Publish ¶
Publish sends a message to one or many readers subscribed to msg.StreamName (aka. fan-out) in a fire-and-forget way meaning the internal writer only cares about writing to the queue whereas subscribers are independent processes.
This routine will fail if Bus is shut down.
func (*Bus) Shutdown ¶
func (b *Bus) Shutdown()
Shutdown disposes allocated resources and signals internal processes for a graceful shutdown.
This operation might block I/O as it waits for in-flight reader processes to finish -either by success or timeout-.
type Config ¶
type Config struct { // Internal queue buffer capacity. Bus will allocate an unbuffered channel if <= 0. QueueBufferFactor int // streams.ReaderHandleFunc maximum process execution duration. ReaderHandlerTimeout time.Duration // logging instance used by internal processes. Logger *log.Logger }
Config Bus configuration parameters.