rskafka/protocol/messages/constants.rs
1use crate::protocol::primitives::{Int32, Int8};
2
3/// The `replica_id` to use to signify the request is being made by a normal consumer.
4pub const NORMAL_CONSUMER: Int32 = Int32(-1);
5
6/// Using `READ_UNCOMMITTED` (`isolation_level = 0`) makes all records visible. With `READ_COMMITTED`
7/// (`isolation_level = 1`), non-transactional and `COMMITTED` transactional records are visible. To be more
8/// concrete, `READ_COMMITTED` returns all data from offsets smaller than the current LSO (last stable offset), and
9/// enables the inclusion of the list of aborted transactions in the result, which allows consumers to discard
10/// `ABORTED` transactional records.
11///
12/// As per [KIP-98] the default is `READ_UNCOMMITTED`.
13///
14/// Added in version 2.
15///
16/// [KIP-98]: https://cwiki.apache.org/confluence/display/KAFKA/KIP-98+-+Exactly+Once+Delivery+and+Transactional+Messaging
17#[derive(Debug, Clone, Copy)]
18pub enum IsolationLevel {
19 ReadCommitted,
20 ReadUncommitted,
21}
22
23impl From<IsolationLevel> for Int8 {
24 fn from(isolation_level: IsolationLevel) -> Self {
25 match isolation_level {
26 IsolationLevel::ReadCommitted => Self(1),
27 IsolationLevel::ReadUncommitted => Self(0),
28 }
29 }
30}
31
32impl Default for IsolationLevel {
33 fn default() -> Self {
34 Self::ReadUncommitted
35 }
36}