use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) struct ConnId(u64);
impl ConnId {
pub(crate) fn next() -> Self {
static NEXT: AtomicU64 = AtomicU64::new(0);
Self(NEXT.fetch_add(1, atomic::Ordering::Relaxed))
}
}
pub(super) type Smits = HashMap<String, (ConnId, String)>;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum BatchPolicy {
AllOrNothing,
PerApp,
}
#[derive(Debug)]
pub(super) enum Registration {
Fresh(ProcessInfo),
AlreadyKnown(ProcessInfo),
}
impl Registration {
pub(super) fn into_info(self) -> ProcessInfo {
match self {
Self::Fresh(info) | Self::AlreadyKnown(info) => info,
}
}
}
#[derive(Debug, Clone)]
pub(crate) struct FieldSet {
pub(crate) app: ResolvedApp,
pub(crate) pending: bool,
pub(crate) warning: Option<String>,
}
#[derive(Debug, Clone)]
pub(crate) struct EnvBatch {
pub(crate) app: Option<ResolvedApp>,
pub(crate) set: Vec<String>,
pub(crate) unchanged: Vec<String>,
pub(crate) collisions: Vec<String>,
}
pub(crate) const DEFAULT_ENVIRONMENT: &str = "production";
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SheepCtl {
Kill {
grace: Duration,
},
}
#[derive(Debug)]
pub(crate) struct Scaled {
pub(crate) instances: Vec<ProcessInfo>,
pub(crate) app: ResolvedApp,
pub(crate) requested: u32,
pub(crate) shortfall: Option<String>,
}
impl Scaled {
pub(crate) fn achieved(&self) -> u32 {
u32::try_from(self.instances.len()).unwrap_or(u32::MAX)
}
}
#[derive(Debug)]
pub(crate) struct Applied {
pub(crate) name: String,
pub(crate) applied: Vec<String>,
pub(crate) pending: Vec<String>,
pub(crate) refused: Option<String>,
pub(crate) app: Option<ResolvedApp>,
}
#[derive(Debug)]
pub(super) struct PendingReply {
pub(super) remaining: HashSet<u32>,
pub(super) results: Vec<ProcessInfo>,
pub(super) reply: ReplyKind,
}