Struct chronicle::queue::RollCycle

#[repr(transparent)]
pub struct RollCycle { pub repr: u8, }
Expand description

A Chronicle Queue is a logical view of a directory on the file system. The queue data is split across multiple files, each of which contains data belonging to a single cycle. The length of the cycle is determined by the rollcycle parameter passed to the queue builder.

Example options are:

  • RollCycle::Daily: events stored in the queue will be grouped into 24-hour periods
  • RollCycle::Hourly: a new queue file will be created every hour

As new files are created (the queue is rolled) to accommodate events being written to the queue, a persisted data-structure (the .cq4t file) is updated with the lowest and highest cycle numbers present in the directory. Maintaining this table allows an ExcerptTailer to busy-spin waiting for new data to be appended to the queue, without the need to make costly calls to the file system to check for the existence of new queue files.

The interval for rolling is configured using the queue’s rollcycle attribute, for example:

let queue = queue::SingleChronicleQueueBuilder::new("example")
                .rollcycle(RollCycle::Daily)
                .build()
                .unwrap();

The roll cycle is fixed once the first data is appended to the queue. If an attempt is made to open an existing queue with a different rollcycle passed to the SingleChronicleQueueBuilder then the queue’s existing roll cycle will take priority and be used instead. (A corresponding warning message will also be logged).

Note: file rolling is a relatively expensive operation and it is recommended to schedule rolling during quiet periods wherever possible.

In addition to controlling the frequency of file rolling, the RollCycle also imposes some limits on the maximum number of messages per cycle (ie per .cq4 file). These limits are rarely intrusive, but some use cases will dictate the choice of RollCycle.

The default RollCycle is FastDaily and this is appropriate for most use cases. It is recommended to start with the FastDaily roll cycle then change only when a specific need arises.

The complete list of roll cycles, together with relevant limits are listed in the below table.

Note: Roll cycles with Test in the name are very short duration cycles which can be used to check behaviour on file rolling (eg if bespoke callbacks have been registered). These are not suitable for use outside of testing.

Roll Cycle NameMax number of msgs per cycle (dec / hex)Averaged max number of msgs per second
FiveMinutely1,073,741,824 / 0x400000003,579,139
TenMinutely1,073,741,824 / 0x400000001,789,569
TwentyMinutely1,073,741,824 / 0x400000001,491,308
HalfHourly1,073,741,824 / 0x40000000596,523
FastHourly4,294,967,295 / 0xffffffff1,193,046
TwoHourly4,294,967,295 / 0xffffffff596,523
FourHourly4,294,967,295 / 0xffffffff298,261
SixHourly4,294,967,295 / 0xffffffff198,841
FastDaily4,294,967,295 / 0xffffffff49,710
Minutely67,108,864 / 0x40000001,118,481
Hourly268,435,456 / 0x1000000074,565
Daily4,294,967,295 / 0xffffffff49,710
LargeHourly4,294,967,295 / 0xffffffff49,710
LargeDaily137,438,953,471 / 0x1fffffffff1,590,728
XLargeDaily4,398,046,511,103 / 0x3ffffffffff50,903,316
HugeDaily281,474,976,710,655 / 0xffffffffffff3,257,812,230
SmallDaily536,870,912 / 0x200000006,213
LargeHourlySparse17,179,869,183 / 0x3ffffffff4,772,185
LargeHourlyXSparse4,398,046,511,103 / 0x3ffffffffff1,221,679,586
HugeDailyXSparse281,474,976,710,655 / 0xffffffffffff78,187,493,530
TestSecondly4,294,967,295 / 0xffffffff4,294,967,295
Test4Secondly4,096 / 0x10004,096
TestHourly1,024 / 0x4000
TestDaily64 / 0x400
Test2Daily512 / 0x2000
Test4Daily4,096 / 0x10000
Test8Daily131,072 / 0x200001

Fields§

§repr: u8

Implementations§

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
§

type Id

A type-level representation of the type’s C++ namespace and type name. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.