A partitioned message queueing, routing and delivery library designed for very small messages at very high speeds that don't require disk durability. This makes it quite useful for metrics ingestion pipelines.
Messages are written in the following manner:
- Write to the public
Writer
inwriter.go
, which acquires read lock on writer (can be concurrent). - That writes to all registered
consumerServiceWriter
writers (one per downstream service) in a sequential loop, one after another. - The
consumerServiceWriter
selects a shard by asking message what shard it is and writes immediately to that shard'sshardWriter
, without taking any locks in any of this process (should check for out of bounds of the shard in future). - The
shardWriter
then acquires a read lock and writes it to amessageWriter
. - The
messageWriter
then acquires a write lock on itself and pushes the message onto a queue. - The
messageWriter
has a background routine that periodically acquires it's writeLock and scans the queue for new writes to forward to downstream consumers. - If
messageWriter
is part of asharedShardWriter
it will have many downstream consumer instances. Otherwise, if it's part of areplicatedShardWriter
there is only one consumer instance at a time. - The
consumerWriter
(one per downstream consumer instance) then takes a write lock for the connection index selected every write that it receives. ThemessageWriter
selects the connection index based on the shard ID so that shards should balance the connection they ultimately use to send data downstream to instances (so IO is not blocked on a per downstream instance).