diff --git a/lib/chirp-workflow/core/src/activity.rs b/lib/chirp-workflow/core/src/activity.rs index 988a11c116..10c769b47f 100644 --- a/lib/chirp-workflow/core/src/activity.rs +++ b/lib/chirp-workflow/core/src/activity.rs @@ -8,7 +8,10 @@ use async_trait::async_trait; use global_error::GlobalResult; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use crate::{ActivityCtx, WorkflowError, WorkflowResult}; +use crate::{ + ctx::ActivityCtx, + error::{WorkflowError, WorkflowResult}, +}; #[async_trait] pub trait Activity { diff --git a/lib/chirp-workflow/core/src/compat.rs b/lib/chirp-workflow/core/src/compat.rs index 2f4b5753fa..ccbf815822 100644 --- a/lib/chirp-workflow/core/src/compat.rs +++ b/lib/chirp-workflow/core/src/compat.rs @@ -11,10 +11,14 @@ use crate::{ api::WORKFLOW_TIMEOUT, message::{MessageCtx, SubscriptionHandle}, workflow::SUB_WORKFLOW_RETRY, + OperationCtx, }, + db::{DatabaseHandle, DatabasePostgres}, + error::WorkflowError, message::Message, - DatabaseHandle, DatabasePostgres, Operation, OperationCtx, OperationInput, Signal, Workflow, - WorkflowError, WorkflowInput, + operation::{Operation, OperationInput}, + signal::Signal, + workflow::{Workflow, WorkflowInput}, }; pub async fn dispatch_workflow( diff --git a/lib/chirp-workflow/core/src/ctx/activity.rs b/lib/chirp-workflow/core/src/ctx/activity.rs index 21681fe922..23749e1d66 100644 --- a/lib/chirp-workflow/core/src/ctx/activity.rs +++ b/lib/chirp-workflow/core/src/ctx/activity.rs @@ -2,7 +2,12 @@ use global_error::{GlobalError, GlobalResult}; use rivet_pools::prelude::*; use uuid::Uuid; -use crate::{ctx::OperationCtx, error::WorkflowError, DatabaseHandle, Operation, OperationInput}; +use crate::{ + ctx::OperationCtx, + db::DatabaseHandle, + error::WorkflowError, + operation::{Operation, OperationInput}, +}; #[derive(Clone)] pub struct ActivityCtx { diff --git a/lib/chirp-workflow/core/src/ctx/api.rs b/lib/chirp-workflow/core/src/ctx/api.rs index c2715478b7..9cc7a62c44 100644 --- a/lib/chirp-workflow/core/src/ctx/api.rs +++ b/lib/chirp-workflow/core/src/ctx/api.rs @@ -8,12 +8,16 @@ use uuid::Uuid; use crate::{ ctx::{ message::{MessageCtx, SubscriptionHandle, TailAnchor, TailAnchorResponse}, - operation::OperationCtx, workflow::SUB_WORKFLOW_RETRY, + OperationCtx, }, + db::DatabaseHandle, + error::WorkflowError, error::WorkflowResult, message::{Message, ReceivedMessage}, - DatabaseHandle, Operation, OperationInput, Signal, Workflow, WorkflowError, WorkflowInput, + operation::{Operation, OperationInput}, + signal::Signal, + workflow::{Workflow, WorkflowInput}, }; pub const WORKFLOW_TIMEOUT: Duration = Duration::from_secs(60); diff --git a/lib/chirp-workflow/core/src/ctx/operation.rs b/lib/chirp-workflow/core/src/ctx/operation.rs index c0db0e258d..fd4437a263 100644 --- a/lib/chirp-workflow/core/src/ctx/operation.rs +++ b/lib/chirp-workflow/core/src/ctx/operation.rs @@ -3,7 +3,12 @@ use rivet_pools::prelude::*; use serde::Serialize; use uuid::Uuid; -use crate::{signal::Signal, DatabaseHandle, Operation, OperationInput, WorkflowError}; +use crate::{ + db::DatabaseHandle, + error::WorkflowError, + operation::{Operation, OperationInput}, + signal::Signal, +}; #[derive(Clone)] pub struct OperationCtx { diff --git a/lib/chirp-workflow/core/src/ctx/standalone.rs b/lib/chirp-workflow/core/src/ctx/standalone.rs index c1494d1754..d670633322 100644 --- a/lib/chirp-workflow/core/src/ctx/standalone.rs +++ b/lib/chirp-workflow/core/src/ctx/standalone.rs @@ -10,9 +10,13 @@ use crate::{ workflow::SUB_WORKFLOW_RETRY, MessageCtx, OperationCtx, }, + db::DatabaseHandle, + error::WorkflowError, error::WorkflowResult, message::{Message, ReceivedMessage}, - DatabaseHandle, Operation, OperationInput, Signal, Workflow, WorkflowError, WorkflowInput, + operation::{Operation, OperationInput}, + signal::Signal, + workflow::{Workflow, WorkflowInput}, }; #[derive(Clone)] diff --git a/lib/chirp-workflow/core/src/ctx/test.rs b/lib/chirp-workflow/core/src/ctx/test.rs index 98c40d084a..1a5867a563 100644 --- a/lib/chirp-workflow/core/src/ctx/test.rs +++ b/lib/chirp-workflow/core/src/ctx/test.rs @@ -10,9 +10,13 @@ use crate::{ workflow::SUB_WORKFLOW_RETRY, MessageCtx, OperationCtx, }, + db::{DatabaseHandle, DatabasePostgres}, + error::WorkflowError, message::{Message, ReceivedMessage}, - util, DatabaseHandle, DatabasePostgres, Operation, OperationInput, Signal, Workflow, - WorkflowError, WorkflowInput, + operation::{Operation, OperationInput}, + signal::Signal, + util, + workflow::{Workflow, WorkflowInput}, }; pub struct TestCtx { diff --git a/lib/chirp-workflow/core/src/ctx/workflow.rs b/lib/chirp-workflow/core/src/ctx/workflow.rs index 5d9b4cc0e2..6b7f1243b8 100644 --- a/lib/chirp-workflow/core/src/ctx/workflow.rs +++ b/lib/chirp-workflow/core/src/ctx/workflow.rs @@ -7,15 +7,18 @@ use uuid::Uuid; use crate::{ activity::ActivityId, + activity::{Activity, ActivityInput}, ctx::{ActivityCtx, ListenCtx, MessageCtx}, + db::{DatabaseHandle, PulledWorkflow}, + error::{WorkflowError, WorkflowResult}, event::Event, executable::{closure, AsyncResult, Executable}, listen::{CustomListener, Listen}, message::Message, + registry::RegistryHandle, signal::Signal, util::Location, - Activity, ActivityInput, DatabaseHandle, PulledWorkflow, RegistryHandle, Workflow, - WorkflowError, WorkflowInput, WorkflowResult, + workflow::{Workflow, WorkflowInput}, }; // Time to delay a worker from retrying after an error diff --git a/lib/chirp-workflow/core/src/db/mod.rs b/lib/chirp-workflow/core/src/db/mod.rs index ee5097efe0..59815998b9 100644 --- a/lib/chirp-workflow/core/src/db/mod.rs +++ b/lib/chirp-workflow/core/src/db/mod.rs @@ -3,7 +3,11 @@ use std::{collections::HashMap, sync::Arc}; use uuid::Uuid; use crate::{ - activity::ActivityId, event::Event, util::Location, Workflow, WorkflowError, WorkflowResult, + activity::ActivityId, + error::{WorkflowError, WorkflowResult}, + event::Event, + util::Location, + workflow::Workflow, }; mod postgres; diff --git a/lib/chirp-workflow/core/src/db/postgres.rs b/lib/chirp-workflow/core/src/db/postgres.rs index 7b11c724e8..4d640e1965 100644 --- a/lib/chirp-workflow/core/src/db/postgres.rs +++ b/lib/chirp-workflow/core/src/db/postgres.rs @@ -8,7 +8,11 @@ use super::{ ActivityEventRow, Database, MessageSendEventRow, PulledWorkflow, PulledWorkflowRow, SignalEventRow, SignalRow, SignalSendEventRow, SubWorkflowEventRow, WorkflowRow, }; -use crate::{activity::ActivityId, util, WorkflowError, WorkflowResult}; +use crate::{ + activity::ActivityId, + error::{WorkflowError, WorkflowResult}, + util, +}; const MAX_QUERY_RETRIES: usize = 16; diff --git a/lib/chirp-workflow/core/src/event.rs b/lib/chirp-workflow/core/src/event.rs index ec894efd53..10908ba755 100644 --- a/lib/chirp-workflow/core/src/event.rs +++ b/lib/chirp-workflow/core/src/event.rs @@ -2,8 +2,12 @@ use serde::de::DeserializeOwned; use uuid::Uuid; use crate::{ - activity::ActivityId, ActivityEventRow, MessageSendEventRow, SignalEventRow, - SignalSendEventRow, SubWorkflowEventRow, WorkflowError, WorkflowResult, + activity::ActivityId, + db::{ + ActivityEventRow, MessageSendEventRow, SignalEventRow, SignalSendEventRow, + SubWorkflowEventRow, + }, + error::{WorkflowError, WorkflowResult}, }; /// An event that happened in the workflow run. diff --git a/lib/chirp-workflow/core/src/executable.rs b/lib/chirp-workflow/core/src/executable.rs index dde5e56a16..0e80b0b8bb 100644 --- a/lib/chirp-workflow/core/src/executable.rs +++ b/lib/chirp-workflow/core/src/executable.rs @@ -3,7 +3,7 @@ use std::{future::Future, pin::Pin}; use async_trait::async_trait; use global_error::GlobalResult; -use crate::WorkflowCtx; +use crate::ctx::WorkflowCtx; /// Signifies a retryable executable entity in a workflow. For example: activity, tuple of activities (join), /// closure. diff --git a/lib/chirp-workflow/core/src/lib.rs b/lib/chirp-workflow/core/src/lib.rs index 5f260ec0ad..9cc87259d5 100644 --- a/lib/chirp-workflow/core/src/lib.rs +++ b/lib/chirp-workflow/core/src/lib.rs @@ -14,13 +14,3 @@ mod signal; pub mod util; mod worker; pub mod workflow; - -// TODO: Don't do this, cleanup imports throughout this lib -use activity::*; -use ctx::*; -use db::*; -use error::*; -use operation::*; -use registry::*; -use signal::*; -use workflow::*; diff --git a/lib/chirp-workflow/core/src/operation.rs b/lib/chirp-workflow/core/src/operation.rs index c33f5e2618..08113b7db9 100644 --- a/lib/chirp-workflow/core/src/operation.rs +++ b/lib/chirp-workflow/core/src/operation.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; use async_trait::async_trait; use global_error::GlobalResult; -use crate::OperationCtx; +use crate::ctx::OperationCtx; #[async_trait] pub trait Operation { diff --git a/lib/chirp-workflow/core/src/registry.rs b/lib/chirp-workflow/core/src/registry.rs index 7d449c8568..70a1872399 100644 --- a/lib/chirp-workflow/core/src/registry.rs +++ b/lib/chirp-workflow/core/src/registry.rs @@ -3,7 +3,11 @@ use std::{collections::HashMap, future::Future, pin::Pin, sync::Arc}; use futures_util::FutureExt; use global_error::GlobalError; -use crate::{Workflow, WorkflowCtx, WorkflowError, WorkflowResult}; +use crate::{ + ctx::WorkflowCtx, + error::{WorkflowError, WorkflowResult}, + workflow::Workflow, +}; pub type RegistryHandle = Arc; diff --git a/lib/chirp-workflow/core/src/util.rs b/lib/chirp-workflow/core/src/util.rs index ee8ccbe88c..f9114bb6fd 100644 --- a/lib/chirp-workflow/core/src/util.rs +++ b/lib/chirp-workflow/core/src/util.rs @@ -9,8 +9,12 @@ use tokio::time::{self, Duration}; use uuid::Uuid; use crate::{ - error::WorkflowError, event::Event, ActivityEventRow, MessageSendEventRow, PulledWorkflow, - PulledWorkflowRow, SignalEventRow, SignalSendEventRow, SubWorkflowEventRow, WorkflowResult, + db::{ + ActivityEventRow, MessageSendEventRow, PulledWorkflow, PulledWorkflowRow, SignalEventRow, + SignalSendEventRow, SubWorkflowEventRow, + }, + error::{WorkflowError, WorkflowResult}, + event::Event, }; pub type Location = Box<[usize]>; diff --git a/lib/chirp-workflow/core/src/worker.rs b/lib/chirp-workflow/core/src/worker.rs index 61ac94d9a2..311c6d0d2a 100644 --- a/lib/chirp-workflow/core/src/worker.rs +++ b/lib/chirp-workflow/core/src/worker.rs @@ -3,7 +3,7 @@ use tokio::time::Duration; use tracing::Instrument; use uuid::Uuid; -use crate::{util, DatabaseHandle, RegistryHandle, WorkflowCtx}; +use crate::{ctx::WorkflowCtx, db::DatabaseHandle, registry::RegistryHandle, util}; const TICK_INTERVAL: Duration = Duration::from_millis(200); diff --git a/lib/chirp-workflow/core/src/workflow.rs b/lib/chirp-workflow/core/src/workflow.rs index e4d5e54959..fa233c8a87 100644 --- a/lib/chirp-workflow/core/src/workflow.rs +++ b/lib/chirp-workflow/core/src/workflow.rs @@ -3,7 +3,7 @@ use global_error::GlobalResult; use serde::{de::DeserializeOwned, Serialize}; use std::fmt::Debug; -use crate::WorkflowCtx; +use crate::ctx::WorkflowCtx; #[async_trait] pub trait Workflow {