Add Redis-compatible coordination substrate
This commit is contained in:
parent
182b4d58c7
commit
91ac6dee85
1 changed files with 2481 additions and 1 deletions
54
crates/remora-coordination/src/keys.rs
Normal file
54
crates/remora-coordination/src/keys.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//! Namespaced keys for queue, reservation, lease, progress, cancellation, and permits.
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct KeySpace {
|
||||
prefix: String,
|
||||
}
|
||||
|
||||
impl KeySpace {
|
||||
pub fn new(prefix: impl Into<String>) -> Self {
|
||||
Self {
|
||||
prefix: prefix.into(),
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn prefix(&self) -> &str {
|
||||
&self.prefix
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn queue(&self) -> String {
|
||||
format!("{}queue", self.prefix)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn queue_members(&self) -> String {
|
||||
format!("{}queue:members", self.prefix)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn reserve(&self, job_id: &str) -> String {
|
||||
format!("{}reserve:{job_id}", self.prefix)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn lease(&self, job_id: &str) -> String {
|
||||
format!("{}lease:{job_id}", self.prefix)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn progress(&self, job_id: &str) -> String {
|
||||
format!("{}progress:{job_id}", self.prefix)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn cancel(&self, job_id: &str) -> String {
|
||||
format!("{}cancel:{job_id}", self.prefix)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn permit_slots(&self) -> String {
|
||||
format!("{}permit:slots", self.prefix)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue