Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fill in Ingress trait definition #23

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}