#[cfg(test)]
mod tests;
mod strict_instance_aware_counter;
pub use strict_instance_aware_counter::*;
mod lax_instance_aware_counter;
pub use lax_instance_aware_counter::*;
use uuid::Uuid;
use crate::{DistkitError, RedisKey};
#[async_trait::async_trait]
pub trait InstanceAwareCounterTrait {
fn instance_id(&self) -> &str;
async fn inc(&self, key: &RedisKey, count: i64) -> Result<(i64, i64), DistkitError>;
async fn dec(&self, key: &RedisKey, count: i64) -> Result<(i64, i64), DistkitError>;
async fn set(&self, key: &RedisKey, count: i64) -> Result<(i64, i64), DistkitError>;
async fn set_on_instance(
&self,
key: &RedisKey,
count: i64,
) -> Result<(i64, i64), DistkitError>;
async fn get(&self, key: &RedisKey) -> Result<(i64, i64), DistkitError>;
async fn del(&self, key: &RedisKey) -> Result<(i64, i64), DistkitError>;
async fn del_on_instance(&self, key: &RedisKey) -> Result<(i64, i64), DistkitError>;
async fn clear(&self) -> Result<(), DistkitError>;
async fn clear_on_instance(&self) -> Result<(), DistkitError>;
}
fn generate_instance_id() -> String {
Uuid::new_v4().to_string()
}