Skip to content

Commit

Permalink
Generate pipeline UUIDs (#209)
Browse files Browse the repository at this point in the history
Since the name of the pipelines are now human readable names, we need to
generate UUIDs to be able to store information about the progress in the
database.

This a a temporary step, and a proper patch with a schema update will
come later.

Signed-off-by: Rémy Greinhofer <[email protected]>
  • Loading branch information
rgreinho authored May 28, 2024
1 parent 429bf23 commit 4f4849d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions lambdas/src/bna-fargate-run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use aws_sdk_ecs::types::{
use bnacore::aws::get_aws_parameter_value;
use bnalambdas::{
authenticate_service_account, update_pipeline, AnalysisParameters, BrokenspokePipeline,
BrokenspokeState, Context, AWSS3,
BrokenspokeState, AWSS3,
};
use lambda_runtime::{run, service_fn, Error, LambdaEvent};
use serde::{Deserialize, Serialize};
Expand All @@ -16,7 +16,6 @@ use tracing::info;
struct TaskInput {
analysis_parameters: AnalysisParameters,
aws_s3: AWSS3,
context: Context,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -45,8 +44,7 @@ async fn function_handler(event: LambdaEvent<TaskInput>) -> Result<TaskOutput, E
// Read the task inputs.
let aws_s3 = &event.payload.aws_s3;
let analysis_parameters = &event.payload.analysis_parameters;
let state_machine_context = &event.payload.context;
let (state_machine_id, _) = state_machine_context.execution.ids()?;
let (state_machine_id, _) = (uuid::Uuid::new_v4(), uuid::Uuid::new_v4());

// Update the pipeline status.
let patch_url = format!("{url}/{state_machine_id}");
Expand Down
6 changes: 2 additions & 4 deletions lambdas/src/bna-setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bnacore::{
};
use bnalambdas::{
authenticate_service_account, update_pipeline, AnalysisParameters, BrokenspokePipeline,
BrokenspokeState, Context,
BrokenspokeState,
};
use lambda_runtime::{run, service_fn, Error, LambdaEvent};
use serde::{Deserialize, Serialize};
Expand All @@ -16,7 +16,6 @@ const NEON_MAX_BRANCHES: usize = 20;
#[derive(Deserialize)]
struct TaskInput {
analysis_parameters: AnalysisParameters,
context: Context,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -46,8 +45,7 @@ async fn function_handler(event: LambdaEvent<TaskInput>) -> Result<TaskOutput, E
// Read the task inputs.
info!("Reading input...");
let analysis_parameters = &event.payload.analysis_parameters;
let state_machine_context = &event.payload.context;
let (state_machine_id, _) = state_machine_context.execution.ids()?;
let (state_machine_id, _) = (uuid::Uuid::new_v4(), uuid::Uuid::new_v4());

// Update the pipeline status.
info!("updating pipeline...");
Expand Down
3 changes: 2 additions & 1 deletion lambdas/src/bna-sqs-parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ async fn function_handler(event: LambdaEvent<TaskInput>) -> Result<TaskOutput, E
let analysis_parameters = &event.payload.messages[0].body;
let receipt_handle = &event.payload.messages[0].receipt_handle;
let state_machine_context = &event.payload.context;
let (state_machine_id, scheduled_trigger_id) = state_machine_context.execution.ids()?;
let (state_machine_id, scheduled_trigger_id) =
(uuid::Uuid::new_v4(), Some(uuid::Uuid::new_v4()));

// Create a new pipeline entry.
info!(
Expand Down
5 changes: 2 additions & 3 deletions lambdas/src/bna-teardown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Neon {
branch_id: String,
}

async fn function_handler(event: LambdaEvent<TaskInput>) -> Result<(), Error> {
async fn function_handler(_event: LambdaEvent<TaskInput>) -> Result<(), Error> {
// Retrieve API hostname.
let api_hostname = get_aws_parameter_value("BNA_API_HOSTNAME").await?;

Expand All @@ -36,8 +36,7 @@ async fn function_handler(event: LambdaEvent<TaskInput>) -> Result<(), Error> {
.map_err(|e| format!("cannot authenticate service account: {e}"))?;

// Read the task inputs.
let state_machine_context = &event.payload.context;
let (state_machine_id, _) = state_machine_context.execution.ids()?;
let (state_machine_id, _) = (uuid::Uuid::new_v4(), uuid::Uuid::new_v4());

// Update the pipeline status.
let patch_url = format!("{url}/{state_machine_id}");
Expand Down

0 comments on commit 4f4849d

Please sign in to comment.