pub trait MessageQueueAdapter<V>: Send + Sync{
// Required methods
fn create_iterator(
&self,
for_shard_id: ShardIdent,
partition: QueuePartitionIdx,
ranges: Vec<QueueShardBoundedRange>,
) -> Result<Box<dyn QueueIterator<V>>>;
fn get_statistics(
&self,
partitions: &FastHashSet<QueuePartitionIdx>,
ranges: &[QueueShardBoundedRange],
) -> Result<QueueStatistics>;
fn prepare_diff(
&self,
diff: QueueDiffWithMessages<V>,
block_id_short: BlockIdShort,
diff_hash: &HashBytes,
statistics: DiffStatistics,
check_sequence: Option<DiffZone>,
) -> Result<Option<PendingQueueDiff>>;
fn apply_diff(
&self,
diff: QueueDiffWithMessages<V>,
block_id_short: BlockIdShort,
diff_hash: &HashBytes,
statistics: DiffStatistics,
check_sequence: Option<DiffZone>,
) -> Result<()>;
fn commit_diff(
&self,
mc_top_blocks: Vec<TopBlockIdUpdated>,
partitions: &FastHashSet<QueuePartitionIdx>,
) -> Result<()>;
fn clear_uncommitted_state(&self, top_shards: &[ShardIdent]) -> Result<()>;
fn get_diff_info(
&self,
shard_ident: &ShardIdent,
seqno: u32,
zone: DiffZone,
) -> Result<Option<DiffInfo>>;
fn is_diff_exists(&self, block_id_short: &BlockIdShort) -> Result<bool>;
fn get_last_committed_mc_block_id(&self) -> Result<Option<BlockId>>;
fn get_diffs_tail_len(
&self,
shard_ident: &ShardIdent,
from: &QueueKey,
) -> u32;
fn load_separated_diff_statistics(
&self,
partitions: &FastHashSet<QueuePartitionIdx>,
range: &QueueShardBoundedRange,
) -> Result<SeparatedStatisticsByPartitions>;
fn get_router_and_statistics(
&self,
block_id_short: &BlockIdShort,
diff_info: DiffInfo,
partition: QueuePartitionIdx,
) -> Result<(PartitionRouter, DiffStatistics)>;
}Required Methods§
Sourcefn create_iterator(
&self,
for_shard_id: ShardIdent,
partition: QueuePartitionIdx,
ranges: Vec<QueueShardBoundedRange>,
) -> Result<Box<dyn QueueIterator<V>>>
fn create_iterator( &self, for_shard_id: ShardIdent, partition: QueuePartitionIdx, ranges: Vec<QueueShardBoundedRange>, ) -> Result<Box<dyn QueueIterator<V>>>
Create iterator for specified shard and return it
Sourcefn get_statistics(
&self,
partitions: &FastHashSet<QueuePartitionIdx>,
ranges: &[QueueShardBoundedRange],
) -> Result<QueueStatistics>
fn get_statistics( &self, partitions: &FastHashSet<QueuePartitionIdx>, ranges: &[QueueShardBoundedRange], ) -> Result<QueueStatistics>
Returns statistics for the specified ranges by partition and source shards (equal to iterator ranges)
Sourcefn prepare_diff(
&self,
diff: QueueDiffWithMessages<V>,
block_id_short: BlockIdShort,
diff_hash: &HashBytes,
statistics: DiffStatistics,
check_sequence: Option<DiffZone>,
) -> Result<Option<PendingQueueDiff>>
fn prepare_diff( &self, diff: QueueDiffWithMessages<V>, block_id_short: BlockIdShort, diff_hash: &HashBytes, statistics: DiffStatistics, check_sequence: Option<DiffZone>, ) -> Result<Option<PendingQueueDiff>>
Prepare diff for applying to queue. Returns transaction that should be committed later. Returns None if diff is already applied (duplicate).
Sourcefn apply_diff(
&self,
diff: QueueDiffWithMessages<V>,
block_id_short: BlockIdShort,
diff_hash: &HashBytes,
statistics: DiffStatistics,
check_sequence: Option<DiffZone>,
) -> Result<()>
fn apply_diff( &self, diff: QueueDiffWithMessages<V>, block_id_short: BlockIdShort, diff_hash: &HashBytes, statistics: DiffStatistics, check_sequence: Option<DiffZone>, ) -> Result<()>
Apply diff by storing it to the queue uncommitted zone (waiting for the operation to complete)
Sourcefn commit_diff(
&self,
mc_top_blocks: Vec<TopBlockIdUpdated>,
partitions: &FastHashSet<QueuePartitionIdx>,
) -> Result<()>
fn commit_diff( &self, mc_top_blocks: Vec<TopBlockIdUpdated>, partitions: &FastHashSet<QueuePartitionIdx>, ) -> Result<()>
Commit previously applied diffs, updating commit pointers (waiting for the operation to complete)
fn clear_uncommitted_state(&self, top_shards: &[ShardIdent]) -> Result<()>
Sourcefn get_diff_info(
&self,
shard_ident: &ShardIdent,
seqno: u32,
zone: DiffZone,
) -> Result<Option<DiffInfo>>
fn get_diff_info( &self, shard_ident: &ShardIdent, seqno: u32, zone: DiffZone, ) -> Result<Option<DiffInfo>>
Get diff for the given block from committed and/or uncommitted zone
Sourcefn is_diff_exists(&self, block_id_short: &BlockIdShort) -> Result<bool>
fn is_diff_exists(&self, block_id_short: &BlockIdShort) -> Result<bool>
Check if diff exists in state
Sourcefn get_last_committed_mc_block_id(&self) -> Result<Option<BlockId>>
fn get_last_committed_mc_block_id(&self) -> Result<Option<BlockId>>
Get mc block id on which the queue was committed. Returns None if queue was not committed
Sourcefn get_diffs_tail_len(&self, shard_ident: &ShardIdent, from: &QueueKey) -> u32
fn get_diffs_tail_len(&self, shard_ident: &ShardIdent, from: &QueueKey) -> u32
Get diffs tail len.
from - start key for the tail. Diff with max_message == from will be excluded from the tail
Sourcefn load_separated_diff_statistics(
&self,
partitions: &FastHashSet<QueuePartitionIdx>,
range: &QueueShardBoundedRange,
) -> Result<SeparatedStatisticsByPartitions>
fn load_separated_diff_statistics( &self, partitions: &FastHashSet<QueuePartitionIdx>, range: &QueueShardBoundedRange, ) -> Result<SeparatedStatisticsByPartitions>
Load separated diff statistics for the specified partitions and range.
range.from = diff with max_message == range.from will be excluded in statistics;
range.to = diff with max_message == range.to will be included in statistics
Sourcefn get_router_and_statistics(
&self,
block_id_short: &BlockIdShort,
diff_info: DiffInfo,
partition: QueuePartitionIdx,
) -> Result<(PartitionRouter, DiffStatistics)>
fn get_router_and_statistics( &self, block_id_short: &BlockIdShort, diff_info: DiffInfo, partition: QueuePartitionIdx, ) -> Result<(PartitionRouter, DiffStatistics)>
Get partition router and statistics for the specified block