use std::sync::atomic::AtomicU32;
use rocketmq_remoting::protocol::body::ha_runtime_info::HARuntimeInfo;
use rocketmq_rust::ArcMut;
use tokio::sync::Notify;
use crate::ha::general_ha_client::GeneralHAClient;
use crate::ha::general_ha_connection::GeneralHAConnection;
use crate::ha::ha_connection_state_notification_request::HAConnectionStateNotificationRequest;
use crate::log_file::group_commit_request::GroupCommitRequest;
use crate::store_error::HAResult;
#[trait_variant::make(HAService: Send)]
pub trait RocketHAService: Sync {
async fn start(&mut self) -> HAResult<()>;
async fn shutdown(&self);
async fn change_to_master(&self, master_epoch: i32) -> HAResult<bool>;
async fn change_to_master_when_last_role_is_master(&self, master_epoch: i32) -> HAResult<bool>;
async fn change_to_slave(
&self,
new_master_addr: &str,
new_master_epoch: i32,
slave_id: Option<i64>,
) -> HAResult<bool>;
async fn change_to_slave_when_master_not_change(
&self,
new_master_addr: &str,
new_master_epoch: i32,
) -> HAResult<bool>;
async fn update_master_address(&self, new_addr: &str);
async fn update_ha_master_address(&self, new_addr: &str);
fn in_sync_replicas_nums(&self, master_put_where: i64) -> i32;
fn get_connection_count(&self) -> &AtomicU32;
async fn put_request(&self, request: ArcMut<GroupCommitRequest>);
fn put_group_connection_state_request(&self, request: HAConnectionStateNotificationRequest);
async fn get_connection_list(&self) -> Vec<ArcMut<GeneralHAConnection>>;
fn get_ha_client(&self) -> Option<&GeneralHAClient>;
fn get_ha_client_mut(&mut self) -> Option<&mut GeneralHAClient>;
fn get_push_to_slave_max_offset(&self) -> i64;
fn get_runtime_info(&self, master_put_where: i64) -> HARuntimeInfo;
fn get_wait_notify_object(&self) -> &Notify;
async fn is_slave_ok(&self, master_put_where: i64) -> bool;
}