-
Notifications
You must be signed in to change notification settings - Fork 137
/
mod.rs
38 lines (34 loc) · 1.3 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/// Akri API Version
pub const API_VERSION: &str = "v0";
/// Version for kube:Api::watch
/// TODO: use kube_runtime::watcher::watcher to avoid managing version
pub const WATCH_VERSION: &str = "0";
/// Akri CRD Namespace
pub const API_NAMESPACE: &str = "akri.sh";
/// Akri Configuration CRD name
pub const API_CONFIGURATIONS: &str = "configurations";
/// Akri Instance CRD name
pub const API_INSTANCES: &str = "instances";
/// Akri prefix
pub const AKRI_PREFIX: &str = "akri.sh";
/// Container Annotation name prefix used to store slot name
pub const AKRI_SLOT_ANNOTATION_NAME_PREFIX: &str = "akri.agent.slot-";
pub mod configuration;
pub mod instance;
pub mod metrics;
pub mod retry {
use rand::random;
use std::time::Duration;
use tokio::time;
/// Maximum amount of tries to update or create an instance
pub const MAX_INSTANCE_UPDATE_TRIES: i8 = 5;
/// This method will delay a random percentage of up to 200ms
///
/// Wait for random amount of time to stagger update/create requests to etcd from
/// plugins created at the same time from daemonset
pub async fn random_delay() {
let random_decimal: f32 = random::<f32>();
let random_delay_0_to_200: u64 = (200_f32 * random_decimal) as u64;
time::sleep(Duration::from_millis(random_delay_0_to_200)).await;
}
}