-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load Config and set up execution pipeline.
This commit sets up the execution pipeline. I had some scratch code in a function `setup_pipeline` in `src/pipeline/mod.rs` that would create a mock pipeline. This commit instantiates (mostly real) objects in `src/cmd/deploy.rs` instead. Since objects like the `Monitor` are initialized based on user config, I think it makes sense that the config plumbing lives in the `cmd` module instead of the `pipeline` module, which offers better separation between setup logic and application logic. This commit also create a real AWS CloudWatch `Monitor`. The previous version, which I ultimately deprecated, was way out of place in the wrong module.
- Loading branch information
1 parent
1787b98
commit 7ca52fc
Showing
8 changed files
with
1,366 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use async_trait::async_trait; | ||
use aws_config::BehaviorVersion; | ||
|
||
use crate::{metrics::ResponseStatusCode, stats::CategoricalObservation}; | ||
use aws_sdk_cloudwatch::client::Client as AwsClient; | ||
|
||
use super::Monitor; | ||
|
||
pub struct CloudWatch { | ||
client: AwsClient, | ||
} | ||
|
||
impl CloudWatch { | ||
pub async fn new() -> Self { | ||
// We don't need a particular version, but we should pin to a particular | ||
// behavior so it doens't accidently slip if `latest` gets updated | ||
// without our knowledge. | ||
let behavior = BehaviorVersion::v2024_03_28(); | ||
let config = aws_config::load_defaults(behavior).await; | ||
let client = aws_sdk_cloudwatch::Client::new(&config); | ||
Self { client } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl Monitor for CloudWatch { | ||
type Item = CategoricalObservation<5, ResponseStatusCode>; | ||
|
||
async fn query(&mut self) -> Vec<Self::Item> { | ||
todo!("CloudWatch monitoring not yet implemented."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
use crate::Pipeline; | ||
use crate::adapters::ChiSquareEngine; | ||
use crate::adapters::{CloudWatch, MockIngress}; | ||
use crate::{adapters::Monitor, Pipeline}; | ||
use miette::Result; | ||
|
||
#[derive(Default)] | ||
pub struct Deploy; | ||
|
||
impl Deploy { | ||
/// initialize the deployment command. Using a constructor here | ||
/// is largely to make the look-and-feel of the cmd API similar | ||
/// between different commands. | ||
pub fn new() -> Self { | ||
Self | ||
} | ||
|
||
/// deploy the canary, monitoring it, and ultimately promoting | ||
/// or yanking the deployment. | ||
pub async fn dispatch(self) -> Result<()> { | ||
// • Load the monitor from the user's config. | ||
let monitor = CloudWatch::load_from_conf().await?; | ||
// • Set up our deployment pipeline. | ||
Pipeline::run().await | ||
Pipeline::builder() | ||
.monitor(monitor) | ||
.engine(ChiSquareEngine::new()) | ||
.ingress(MockIngress) | ||
.build() | ||
// Run the pipeline to completion. | ||
.run() | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters