From 16341a0ef26324d078f2e6fe3a4c8fdd87055801 Mon Sep 17 00:00:00 2001 From: Kartik Shah Date: Tue, 7 Oct 2025 19:06:16 +0530 Subject: [PATCH] feat: job crate dummy job --- Cargo.lock | 205 +++++++++++++++++++----- Cargo.toml | 1 + bats/dummy_job.bats | 51 ++++++ migrations/20250904065521_job_setup.sql | 56 +++++++ src/api/server/convert.rs | 3 + src/app/error.rs | 3 + src/app/mod.rs | 9 ++ src/job/dummy.rs | 34 ++++ src/job/error.rs | 2 + src/job/mod.rs | 25 ++- 10 files changed, 347 insertions(+), 42 deletions(-) create mode 100644 bats/dummy_job.bats create mode 100644 migrations/20250904065521_job_setup.sql create mode 100644 src/job/dummy.rs diff --git a/Cargo.lock b/Cargo.lock index c4dfd12f..b9a12f25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.88" +version = "0.1.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", @@ -364,7 +364,7 @@ dependencies = [ "js-sys", "log", "miniscript", - "rand", + "rand 0.8.5", "serde", "serde_json", "sled", @@ -546,6 +546,7 @@ dependencies = [ "fedimint-tonic-lnd", "futures", "hex", + "job", "miniscript", "opentelemetry", "opentelemetry-otlp", @@ -553,7 +554,7 @@ dependencies = [ "prost 0.12.6", "prost-wkt-types", "protobuf-src", - "rand", + "rand 0.8.5", "regex", "reqwest", "reqwest-middleware", @@ -870,7 +871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "typenum", ] @@ -1031,6 +1032,12 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + [[package]] name = "either" version = "1.13.0" @@ -1598,7 +1605,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -1696,7 +1703,7 @@ dependencies = [ "http-body 1.0.1", "hyper 1.5.1", "pin-project-lite", - "socket2", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -1877,7 +1884,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" dependencies = [ "bitmaps", - "rand_core", + "rand_core 0.6.4", "rand_xoshiro", "serde", "sized-chunks", @@ -1934,6 +1941,17 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" +[[package]] +name = "io-uring" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "libc", +] + [[package]] name = "ipnet" version = "2.10.1" @@ -1970,6 +1988,28 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "job" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc97547bab9416fb9e5490474afef9f452611dbff8a478cf9dc3cf5bb093bdb" +dependencies = [ + "async-trait", + "chrono", + "derive_builder", + "es-entity", + "futures", + "rand 0.9.2", + "serde", + "serde_json", + "serde_with", + "sqlx", + "thiserror 2.0.12", + "tokio", + "tracing", + "uuid", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -2043,9 +2083,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.165" +version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" +checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" [[package]] name = "libm" @@ -2193,7 +2233,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand", + "rand 0.8.5", "smallvec", "zeroize", ] @@ -2329,7 +2369,7 @@ dependencies = [ "once_cell", "opentelemetry", "percent-encoding", - "rand", + "rand 0.8.5", "serde_json", "thiserror 1.0.69", "tokio", @@ -2724,7 +2764,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls 0.23.18", - "socket2", + "socket2 0.5.7", "thiserror 2.0.12", "tokio", "tracing", @@ -2738,7 +2778,7 @@ checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", "getrandom 0.2.15", - "rand", + "rand 0.8.5", "ring", "rustc-hash", "rustls 0.23.18", @@ -2759,7 +2799,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2", + "socket2 0.5.7", "tracing", "windows-sys 0.59.0", ] @@ -2792,8 +2832,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -2803,7 +2853,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", ] [[package]] @@ -2815,13 +2875,22 @@ dependencies = [ "getrandom 0.2.15", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] + [[package]] name = "rand_xoshiro" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -2842,6 +2911,26 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "regex" version = "1.11.1" @@ -2968,7 +3057,7 @@ checksum = "493b4243e32d6eedd29f9a398896e35c6943a123b55eec97dcaee98310d25810" dependencies = [ "anyhow", "chrono", - "rand", + "rand 0.8.5", ] [[package]] @@ -3027,7 +3116,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8", - "rand_core", + "rand_core 0.6.4", "signature", "spki", "subtle", @@ -3044,7 +3133,7 @@ dependencies = [ "borsh", "bytes", "num-traits", - "rand", + "rand 0.8.5", "rkyv", "serde", "serde_json", @@ -3199,6 +3288,30 @@ dependencies = [ "sdd", ] +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -3234,7 +3347,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" dependencies = [ "bitcoin_hashes", - "rand", + "rand 0.8.5", "secp256k1-sys", "serde", ] @@ -3294,15 +3407,17 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.11.0" +version = "3.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.6.0", + "schemars 0.9.0", + "schemars 1.0.4", "serde", "serde_derive", "serde_json", @@ -3312,11 +3427,11 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.11.0" +version = "3.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +checksum = "327ada00f7d64abaac1e55a6911e90cf665aa051b9a561c7006c157f4633135e" dependencies = [ - "darling 0.20.11", + "darling 0.21.3", "proc-macro2", "quote", "syn 2.0.104", @@ -3423,7 +3538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -3492,6 +3607,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + [[package]] name = "spin" version = "0.9.8" @@ -3680,7 +3805,7 @@ dependencies = [ "memchr", "once_cell", "percent-encoding", - "rand", + "rand 0.8.5", "rsa", "rust_decimal", "serde", @@ -3721,7 +3846,7 @@ dependencies = [ "md-5", "memchr", "once_cell", - "rand", + "rand 0.8.5", "rust_decimal", "serde", "serde_json", @@ -4014,20 +4139,22 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", + "io-uring", "libc", "mio", "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", - "socket2", + "slab", + "socket2 0.6.0", "tokio-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4042,9 +4169,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -4192,7 +4319,7 @@ dependencies = [ "percent-encoding", "pin-project", "prost 0.13.3", - "socket2", + "socket2 0.5.7", "tokio", "tokio-stream", "tower 0.4.13", @@ -4251,7 +4378,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand", + "rand 0.8.5", "slab", "tokio", "tokio-util", diff --git a/Cargo.toml b/Cargo.toml index 39da81d8..9427bc82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" fail-on-warnings = [] [dependencies] +job_crate = { package = "job", version = "0.1.12" } es-entity = "0.9.0" sqlx-ledger = { version = "0.11.5", features = ["otel"] } diff --git a/bats/dummy_job.bats b/bats/dummy_job.bats new file mode 100644 index 00000000..26908595 --- /dev/null +++ b/bats/dummy_job.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env bats + +load "helpers" + +setup_file() { + restart_bitcoin_stack + reset_pg + bitcoind_init + start_daemon + bria_init +} + +teardown_file() { + stop_daemon +} + +@test "dummy_job: Verify job exists in database" { + # Wait a few seconds for daemon to initialize + sleep 10 + + # Query the jobs table to check if dummy job exists + job_count=$(${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -t -c "SELECT COUNT(*) FROM jobs WHERE job_type = 'dummy';") + + # Trim whitespace + job_count=$(echo $job_count | xargs) + + if [[ $job_count -lt 1 ]]; then + echo "Dummy job not found in database" + echo "Available jobs:" + ${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -c "SELECT job_type, created_at FROM jobs;" + exit 1 + fi + + echo "Found $job_count dummy job(s) in database" +} + +@test "dummy_job: Verify job has execution scheduled" { + # Check if there are any scheduled executions for the dummy job + exec_count=$(${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -t -c "SELECT COUNT(*) FROM job_executions je JOIN jobs j ON je.id = j.id WHERE j.job_type = 'dummy';") + + # Trim whitespace + exec_count=$(echo $exec_count | xargs) + + if [[ $exec_count -lt 1 ]]; then + echo "No executions scheduled for dummy job" + exit 1 + fi + + echo "Found $exec_count scheduled execution(s) for dummy job" +} + diff --git a/migrations/20250904065521_job_setup.sql b/migrations/20250904065521_job_setup.sql new file mode 100644 index 00000000..d5a70a90 --- /dev/null +++ b/migrations/20250904065521_job_setup.sql @@ -0,0 +1,56 @@ +CREATE TABLE jobs ( + id UUID PRIMARY KEY, + unique_per_type BOOLEAN NOT NULL, + job_type VARCHAR NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); +CREATE UNIQUE INDEX idx_unique_job_type ON jobs (job_type) WHERE unique_per_type = TRUE; + +CREATE TABLE job_events ( + id UUID NOT NULL REFERENCES jobs(id), + sequence INT NOT NULL, + event_type VARCHAR NOT NULL, + event JSONB NOT NULL, + context JSONB DEFAULT NULL, + recorded_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + UNIQUE(id, sequence) +); + +CREATE TYPE JobExecutionState AS ENUM ('pending', 'running'); + +CREATE TABLE job_executions ( + id UUID REFERENCES jobs(id) NOT NULL UNIQUE, + job_type VARCHAR NOT NULL, + attempt_index INT NOT NULL DEFAULT 1, + state JobExecutionState NOT NULL DEFAULT 'pending', + execution_state_json JSONB, + execute_at TIMESTAMPTZ, + alive_at TIMESTAMPTZ NOT NULL, + created_at TIMESTAMPTZ NOT NULL +); + +CREATE OR REPLACE FUNCTION notify_job_execution_insert() RETURNS TRIGGER AS $$ +BEGIN + PERFORM pg_notify('job_execution', ''); + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + +CREATE OR REPLACE FUNCTION notify_job_execution_update() RETURNS TRIGGER AS $$ +BEGIN + IF NEW.execute_at IS DISTINCT FROM OLD.execute_at THEN + PERFORM pg_notify('job_execution', ''); + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql; + +CREATE TRIGGER job_executions_notify_insert_trigger +AFTER INSERT ON job_executions +FOR EACH STATEMENT +EXECUTE FUNCTION notify_job_execution_insert(); + +CREATE TRIGGER job_executions_notify_update_trigger +AFTER UPDATE ON job_executions +FOR EACH STATEMENT +EXECUTE FUNCTION notify_job_execution_update(); diff --git a/src/api/server/convert.rs b/src/api/server/convert.rs index 7bc1a32e..4fcf4ff1 100644 --- a/src/api/server/convert.rs +++ b/src/api/server/convert.rs @@ -718,6 +718,9 @@ impl From for tonic::Status { ApplicationError::CouldNotParseAddress(_) => { tonic::Status::invalid_argument(err.to_string()) } + ApplicationError::JobCrateJobError(_) => { + tonic::Status::internal(err.to_string()) + } _ => tonic::Status::internal(err.to_string()), } } diff --git a/src/app/error.rs b/src/app/error.rs index 9ba387d7..b6a1a264 100644 --- a/src/app/error.rs +++ b/src/app/error.rs @@ -1,5 +1,6 @@ use chacha20poly1305; use thiserror::Error; +use job_crate::error::JobError as JobCrateJobError; use crate::{ address::error::AddressError, @@ -81,6 +82,8 @@ pub enum ApplicationError { CouldNotDecryptKey(chacha20poly1305::Error), #[error("AddressError - Could not parse the address: {0}")] CouldNotParseAddress(#[from] bitcoin::AddressError), + #[error("JobCrateError - Sqlx: {0}")] + JobCrateJobError(#[from] JobCrateJobError), } impl From for ApplicationError { diff --git a/src/app/mod.rs b/src/app/mod.rs index 1b4cc206..bfde0c67 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -8,6 +8,7 @@ use std::collections::HashMap; pub use config::*; use error::*; +use job_crate::{Jobs, JobSvcConfig}; use crate::{ account::balance::AccountBalanceSummary, @@ -86,6 +87,13 @@ impl App { fees_client.clone(), ) .await?; + + let mut jobs = Jobs::init(JobSvcConfig::builder().pool(pool.clone()).build().expect("Couldn't build JobSvcConfig")).await?; + + job::spawn_dummy(&jobs).await?; + + jobs.start_poll().await?; + Self::spawn_sync_all_wallets(pool.clone(), config.jobs.sync_all_wallets_delay).await?; Self::spawn_process_all_payout_queues( pool.clone(), @@ -97,6 +105,7 @@ impl App { config.jobs.respawn_all_outbox_handlers_delay, ) .await?; + let app = Self { outbox, profiles: Profiles::new(&pool), diff --git a/src/job/dummy.rs b/src/job/dummy.rs new file mode 100644 index 00000000..f0729245 --- /dev/null +++ b/src/job/dummy.rs @@ -0,0 +1,34 @@ +use async_trait::async_trait; +use serde::{Deserialize, Serialize}; +use job_crate::*; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct DummyJobConfig; + +impl JobConfig for DummyJobConfig { + type Initializer = DummyJobInit; +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct DummyJobInit; +impl JobInitializer for DummyJobInit { + fn job_type() -> JobType { + JobType::new("dummy") + } + + fn init(&self, _job: &Job) -> Result, Box> { + Ok(Box::new(DummyJobRunner)) + } +} + +struct DummyJobRunner; + +#[async_trait] +impl JobRunner for DummyJobRunner { + async fn run(&self, _current_job: CurrentJob) -> Result> { + tracing::info!("Dummy job running!"); + tokio::time::sleep(std::time::Duration::from_millis(100)).await; + tracing::info!("Dummy job completed successfully"); + Ok(JobCompletion::Complete) + } +} diff --git a/src/job/error.rs b/src/job/error.rs index c9fc2e98..6e78acb3 100644 --- a/src/job/error.rs +++ b/src/job/error.rs @@ -58,6 +58,8 @@ pub enum JobError { PsbtMissingInSigningSessions, #[error("JobError - psbt::Error: {0}")] PsbtError(#[from] psbt::Error), + #[error("JobCrateError: {0}")] + JobCrateError(#[from] job_crate::error::JobError), } impl JobExecutionError for JobError {} diff --git a/src/job/mod.rs b/src/job/mod.rs index a7072ef0..d365277e 100644 --- a/src/job/mod.rs +++ b/src/job/mod.rs @@ -6,6 +6,7 @@ mod executor; mod populate_outbox; mod sync_wallet; +pub mod dummy; pub mod error; pub mod process_payout_queue; @@ -16,13 +17,12 @@ use tracing::instrument; use uuid::{uuid, Uuid}; use crate::{ - account::*, address::Addresses, app::BlockchainConfig, batch::*, fees::FeesClient, - ledger::Ledger, outbox::*, payout::*, payout_queue::*, primitives::*, signing_session::*, - utxo::Utxos, wallet::*, xpub::*, + account::*, address::Addresses, app::BlockchainConfig, batch::*, fees::FeesClient, ledger::Ledger, outbox::*, payout::*, payout_queue::*, primitives::*, signing_session::*, utxo::Utxos, wallet::*, xpub::* }; use batch_broadcasting::BatchBroadcastingData; use batch_signing::BatchSigningData; use batch_wallet_accounting::BatchWalletAccountingData; +use dummy::{DummyJobConfig, DummyJobInit}; use error::JobError; pub use executor::JobExecutionError; use executor::JobExecutor; @@ -611,6 +611,25 @@ pub async fn spawn_respawn_all_outbox_handlers( } } +#[instrument(name = "job.spawn_dummy", skip_all, fields(error, error.level, error.message), err)] +pub async fn spawn_dummy( + jobs: &job_crate::Jobs +) -> Result<(), JobError> { + tracing::info!("Attempting to spawn dummy job"); + let job_config = DummyJobConfig; + match jobs.add_initializer_and_spawn_unique(DummyJobInit, job_config).await { + Ok(_) => { + tracing::info!("Successfully spawned dummy job"); + Ok(()) + } + Err(e) => { + tracing::error!("Failed to spawn dummy job: {}", e); + crate::tracing::insert_error_fields(tracing::Level::ERROR, &e); + Err(e.into()) + } + } +} + fn schedule_payout_queue_channel_arg(payout_queue_id: PayoutQueueId) -> String { format!("payout_queue_id:{payout_queue_id}") }