Skip to content

Commit

Permalink
chore(workflows): clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Jul 19, 2024
1 parent 033253f commit a4a4453
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 33 deletions.
5 changes: 4 additions & 1 deletion lib/chirp-workflow/core/src/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions lib/chirp-workflow/core/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<I, B>(
Expand Down
7 changes: 6 additions & 1 deletion lib/chirp-workflow/core/src/ctx/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions lib/chirp-workflow/core/src/ctx/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion lib/chirp-workflow/core/src/ctx/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion lib/chirp-workflow/core/src/ctx/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 6 additions & 2 deletions lib/chirp-workflow/core/src/ctx/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions lib/chirp-workflow/core/src/ctx/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/chirp-workflow/core/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion lib/chirp-workflow/core/src/db/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions lib/chirp-workflow/core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/chirp-workflow/core/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions lib/chirp-workflow/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
2 changes: 1 addition & 1 deletion lib/chirp-workflow/core/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion lib/chirp-workflow/core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Registry>;

Expand Down
8 changes: 6 additions & 2 deletions lib/chirp-workflow/core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]>;
Expand Down
2 changes: 1 addition & 1 deletion lib/chirp-workflow/core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion lib/chirp-workflow/core/src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a4a4453

Please sign in to comment.