class

LavinMQ::MessageStore

Inherits Reference < Object

Message store This handles writing msgs to segments on disk Keeping a list of deleted messages in memory and on disk You can shift through the message store, but not requeue msgs That has to be handled at another layer Writes messages to segments on disk Messages are refered to as SegmentPositions Deleted messages are written to acks.#{segment}

Constants

Log = LavinMQ::Log.for("message_store")
PURGE_YIELD_INTERVAL = 16384
READAHEAD_MIN_BYTES_PER_SECOND = 1024 * 1024

A reader that got through its previous segment at least this fast gets readahead for its next one. A slower reader isn't waiting on the disk, so readahead wouldn't speed it up. Reading a segment a page per fault, without readahead, is faster than this even on slow disks, so a reader that is held back by the disk still gets it.

Constructors

new(msg_dir : String, replicator : Clustering::Replicator | Nil, durable : Bool = true, metadata : ::Log::Metadata = ::Log::Metadata.empty, persister : Persister | Nil = nil)
Source

Instance methods

[](sp : SegmentPosition) : BytesMessage
Source
avg_bytesize

Called without the queue's lock (HTTP API, stats), so @size and @bytesize can change in between the reads

Source
bytesize
Source
close
Source
closed
Source
delete(sp) : Nil
Source
delete
Source
empty
Source
empty?
Source
envelope(sp : SegmentPosition, redelivered = false) : Envelope

Like #[], as an envelope, with the segment position made from the message

Source
first?
Source
purge(max_count : Int = UInt32::MAX) : UInt32

Deletes all "ready" messages (not unacked)

Source
purge_all
Source
push(msg) : SegmentPosition
Source
requeue(sp : SegmentPosition)
Source
shift?(consumer = nil) : Envelope | Nil

The envelope points into the segment, so it's only valid while the lock guarding the store is held, see #shift_with_lease? for using it outside it

Source
shift_with_lease?(lock : Mutex, consumer = nil, & : Envelope -> _) : Bool

Shifts the next message, under lock, and yields it outside the lock with its segment kept mapped until the block returns, even if the segment is deleted or the store closed meanwhile. For deliveries, which can be suspended in a socket write. Returns false if there was no message.

Source
size
Source

Nested types