Skip to content

Commit

Permalink
WIP: Fill in Ingress trait definition
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieMcKinstry committed Nov 14, 2024
1 parent eff0048 commit 08654b9
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/adapters/ingresses/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
pub trait Ingress {}
use async_trait::async_trait;
use miette::Result;

/// Ingresses are responsible for (1) controlling how much traffic the canary
/// gets (hence the name ingress, since it functions like a virtual LB) and
/// (2) deploying, yanking, and promoting both the canary and the baseline.
#[async_trait]
pub trait Ingress {
/// Deploy the canary app. Do not assign it any traffic.
async fn deploy(&mut self) -> Result<()>;

// TODO: define the other methods on this type.
// async fn yank_canary(&mut self) -> Result<()>;
// async fn promote_canary(&mut self) -> Result<()>;
// async fn set_canary_traffic(&mut self, percent: u8);
}

pub struct MockIngress;
impl Ingress for MockIngress {}

#[async_trait]
impl Ingress for MockIngress {
async fn deploy(&mut self) -> Result<()> {
todo!()
}
}

impl From<MockIngress> for BoxIngress {
fn from(value: MockIngress) -> Self {
Expand All @@ -12,3 +33,6 @@ impl From<MockIngress> for BoxIngress {
/// Convenience alias since this type is often dynamically
/// dispatched.
pub type BoxIngress = Box<dyn Ingress>;

#[cfg(test)]
mod tests {}

0 comments on commit 08654b9

Please sign in to comment.