use tokio::sync::oneshot;

use super::types::{ExecuteFn, ExecuteIfCachedFn, ExecuteMutFn};
use super::{DefaultCommitPolicy, InnerCommitPolicy, TakenData};
use crate::{ShardError, ShardStats, UpstreamError};

pub(crate) enum InternalMessage<Key, Data> {
    DataLoadResult(Key, Result<Data, UpstreamError>),
    DataCommitResult(Key, Result<(), UpstreamError>),
    DoExpeditedExpirationProbe,
}

pub(super) enum ServiceHandleMessage<Key, Data> {
    Execute(Key, ExecuteFn<Data>),
    ExecuteIfCached(Key, ExecuteIfCachedFn<Data>),
    ExecuteMut(Key, ExecuteMutFn<Data>),
    GetStats(oneshot::Sender<ShardStats>),
    TakeData(Key, TakeDataSender<Key, Data>),
    Stop,
}

pub(super) type TakeDataSender<Key, Data> = oneshot::Sender<Option<TakenData<Key, Data>>>;
