Module kekbit::core

source · []
Expand description

Provides the components and functions required to work with memory mapped data channels.

Structs

A handler which chains two handlers. Chaining mulltiple such handlers will generate a complex chain of handlers used to preproces/write/postprocess a record.

Defines and validates the metadata associated with a channel.

Handler which adds a sequence id to a record.

An implementation of the Reader which access a persistent channel through memory mapping. A ShmReader must be created using the shm_reader function.

Implementation of the Writer which access a persistent channel through memory mapping, A ShmWriter must be created using the shm_writer function. Any ShmWriter exclusively holds the channel is bound to, and it is not thread safe. If multiple threads must write into a channel they should be externally synchronized.

A Reader which decorates another reader with a channel timeout feature. As soon as this reader reaches the channel watermark, it starts a timer. If no new record is written into the channel until the timer triggers the channel will be marked as exhausted. Usually the timeout and the timeout tick unit will be read from a persistent channel metadata.

Handler which adds a timestamp to a record using a given tick unit. This is probably the most used decorator.

A non-blocking iterator over messages in the channel. Each call to next returns a message if there is one ready to be received. The iterator never blocks waiting for a message.

Enums

A TickUnit represents a specific time duration but does not maintain time information, it only helps define the time granularity required to used in various contexts by all kekbit components which share a given channel. For each channel it’s TickUnit will be specified at creation and will never be changed

Functions

Creates a kekbit reader associated to a memory mapped channel.

Decorates a ShmReader with a timeout functionality.

Creates a file backed memory mapped kekbit channel and a writer associate with it.

Returns the path to the file associated with a channel inside a kekbit root folder.

Tries multiple times to create a kekbit reader associated to a memory mapped channel. This function will basically call shm_reader up to tries time unless it succeeds. Between two tries the function will spin/sleep for a about duration_millis/tries milliseconds so potentially could be blocking. This should be the preferred method to create a reader when you are willing to wait until the channel is available.