-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebe7baf
commit cdafbf2
Showing
9 changed files
with
765 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/services/edge/monolith/standalone/workflow-worker/Cargo.toml
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,16 @@ | ||
[package] | ||
name = "edge-monolith-workflow-worker" | ||
version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
chirp-workflow.workspace = true | ||
rivet-config.workspace = true | ||
rivet-health-checks.workspace = true | ||
rivet-metrics.workspace = true | ||
rivet-runtime.workspace = true | ||
|
||
ds.workspace = true | ||
pegboard.workspace = true |
23 changes: 23 additions & 0 deletions
23
packages/services/edge/monolith/standalone/workflow-worker/src/lib.rs
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,23 @@ | ||
use chirp_workflow::prelude::*; | ||
|
||
pub async fn start(config: rivet_config::Config, pools: rivet_pools::Pools) -> GlobalResult<()> { | ||
run_from_env(config, pools).await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[tracing::instrument(skip_all)] | ||
pub async fn run_from_env( | ||
config: rivet_config::Config, | ||
pools: rivet_pools::Pools, | ||
) -> GlobalResult<()> { | ||
let reg = ds::registry()? | ||
.merge(pegboard::registry()?)?; | ||
|
||
let db = db::DatabaseFdbSqliteNats::from_pools(pools.clone())?; | ||
let worker = Worker::new(reg.handle(), db); | ||
|
||
// Start worker | ||
worker.wake_start(config, pools).await?; | ||
bail!("worker exited unexpectedly"); | ||
} |
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,33 @@ | ||
[package] | ||
name = "edge-pegboard" | ||
version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
edition.workspace = true | ||
|
||
[features] | ||
default = ["workflows"] | ||
workflows = ["chirp"] | ||
chirp = ["chirp-workflow", "sqlx", "nix", "server-spec"] | ||
|
||
[dependencies] | ||
chirp-workflow = { workspace = true, optional = true } | ||
lazy_static = "1.4" | ||
nix = { version = "0.27", default-features = false, features = ["user", "signal"], optional = true } | ||
rivet-config.workspace = true | ||
rivet-metrics.workspace = true | ||
schemars = { version = "0.8.21", features = ["url", "uuid1"] } | ||
serde = { version = "1.0.198", features = ["derive"] } | ||
serde_json = "1.0.132" | ||
strum = { version = "0.24", features = ["derive"] } | ||
thiserror = "1.0" | ||
util.workspace = true | ||
uuid = "1.11.0" | ||
|
||
pegboard.workspace = true | ||
server-spec = { workspace = true, optional = true } | ||
|
||
[dependencies.sqlx] | ||
optional = true | ||
workspace = true | ||
features = [ "json", "ipnetwork" ] |
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,16 @@ | ||
#[cfg(feature = "chirp")] | ||
use chirp_workflow::prelude::*; | ||
|
||
#[cfg(feature = "workflows")] | ||
pub mod workflows; | ||
|
||
#[cfg(feature = "workflows")] | ||
pub fn registry() -> WorkflowResult<Registry> { | ||
use workflows::*; | ||
|
||
let mut registry = Registry::new(); | ||
registry.register_workflow::<client::Workflow>()?; | ||
registry.register_workflow::<actor::Workflow>()?; | ||
|
||
Ok(registry) | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/services/edge/pegboard/src/workflows/actor/migrations.rs
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,26 @@ | ||
use chirp_workflow::prelude::*; | ||
|
||
use super::Input; | ||
|
||
pub fn run(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResult<()> { | ||
ctx.activity(MigrateInitInput {}).await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Hash)] | ||
struct MigrateInitInput {} | ||
|
||
#[activity(MigrateInit)] | ||
async fn migrate_init(ctx: &ActivityCtx, &MigrateInitInput) -> GlobalResult<()> { | ||
sql_execute!( | ||
[ctx] | ||
" | ||
CREATE TABLE test ( | ||
) | ||
", | ||
) | ||
.await | ||
.map_err(Into::into) | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/services/edge/pegboard/src/workflows/actor/mod.rs
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,11 @@ | ||
use chirp_workflow::prelude::*; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct Input { | ||
pub actor_id: Uuid, | ||
} | ||
|
||
#[workflow] | ||
pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResult<()> { | ||
Ok(()) | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/services/edge/pegboard/src/workflows/client/migrations.rs
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,26 @@ | ||
use chirp_workflow::prelude::*; | ||
|
||
use super::Input; | ||
|
||
pub fn run(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResult<()> { | ||
ctx.activity(MigrateInitInput {}).await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Hash)] | ||
struct MigrateInitInput {} | ||
|
||
#[activity(MigrateInit)] | ||
async fn migrate_init(ctx: &ActivityCtx, &MigrateInitInput) -> GlobalResult<()> { | ||
sql_execute!( | ||
[ctx] | ||
" | ||
CREATE TABLE test ( | ||
) | ||
", | ||
) | ||
.await | ||
.map_err(Into::into) | ||
} |
Oops, something went wrong.