use std::any::Any;
use std::collections::HashMap;
use std::sync::Arc;
use bytes::Bytes;
use cheetah_string::CheetahString;
use rocketmq_common::common::boundary_type::BoundaryType;
use rocketmq_common::common::message::message_ext_broker_inner::MessageExtBrokerInner;
use crate::base::dispatch_request::DispatchRequest;
use crate::queue::consume_queue::ConsumeQueueTrait;
use crate::queue::ArcConsumeQueue;
use crate::queue::ConsumeQueueTable;
use crate::queue::CqUnit;
#[trait_variant::make(ConsumeQueueStoreTrait: Send)]
pub trait ConsumeQueueStoreInterface: Sync + Any {
fn start(&self);
fn load(&mut self) -> bool;
fn load_after_destroy(&self) -> bool;
async fn recover(&self);
async fn recover_concurrently(&self) -> bool;
fn shutdown(&self) -> bool;
fn destroy(&self);
fn destroy_queue(&self, consume_queue: &dyn ConsumeQueueTrait);
fn flush(&self, consume_queue: &dyn ConsumeQueueTrait, flush_least_pages: i32) -> bool;
async fn clean_expired(&self, min_phy_offset: i64);
fn check_self(&self);
fn delete_expired_file(&self, consume_queue: &dyn ConsumeQueueTrait, min_commit_log_pos: i64) -> i32;
fn is_first_file_available(&self, consume_queue: &dyn ConsumeQueueTrait) -> bool;
fn is_first_file_exist(&self, consume_queue: &dyn ConsumeQueueTrait) -> bool;
fn roll_next_file(&self, consume_queue: &dyn ConsumeQueueTrait, offset: i64) -> i64;
fn truncate_dirty(&self, offset_to_truncate: i64);
fn put_message_position_info_wrapper_with_cq(
&self,
consume_queue: &mut dyn ConsumeQueueTrait,
request: &DispatchRequest,
);
fn put_message_position_info_wrapper(&self, request: &DispatchRequest);
async fn range_query(&self, topic: &CheetahString, queue_id: i32, start_index: i64, num: i32) -> Vec<Bytes>;
async fn get(&self, topic: &CheetahString, queue_id: i32, start_index: i64) -> Bytes;
fn get_consume_queue_table(&self) -> Arc<ConsumeQueueTable>;
fn assign_queue_offset(&self, msg: &mut MessageExtBrokerInner);
fn increase_queue_offset(&self, msg: &MessageExtBrokerInner, message_num: i16);
fn increase_lmq_offset(&self, queue_key: &str, message_num: i16);
fn get_lmq_queue_offset(&self, queue_key: &str) -> i64;
fn get_lmq_num(&self) -> i32;
fn is_lmq_exist(&self, lmq_topic: &str) -> bool;
fn recover_offset_table(&mut self, min_phy_offset: i64);
fn set_topic_queue_table(&mut self, topic_queue_table: HashMap<CheetahString, i64>);
fn remove_topic_queue_table(&mut self, topic: &CheetahString, queue_id: i32);
fn get_topic_queue_table(&self) -> HashMap<CheetahString, i64>;
fn get_max_phy_offset_in_consume_queue(&self, topic: &CheetahString, queue_id: i32) -> Option<i64>;
fn get_max_offset(&self, topic: &CheetahString, queue_id: i32) -> Option<i64>;
fn get_max_phy_offset_in_consume_queue_global(&self) -> i64;
fn get_min_offset_in_queue(&self, topic: &CheetahString, queue_id: i32) -> i64;
fn get_max_offset_in_queue(&self, topic: &CheetahString, queue_id: i32) -> i64;
fn get_offset_in_queue_by_time(
&self,
topic: &CheetahString,
queue_id: i32,
timestamp: i64,
boundary_type: BoundaryType,
) -> i64;
fn find_or_create_consume_queue(&self, topic: &CheetahString, queue_id: i32) -> ArcConsumeQueue;
fn find_consume_queue_map(&self, topic: &CheetahString) -> Option<HashMap<i32, ArcConsumeQueue>>;
fn get_total_size(&self) -> i64;
fn get_store_time(&self, cq_unit: &CqUnit) -> i64;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}