feat: add executor tracing, auto-register primitives, and Default impls

- Add info!-level tracing to workflow executor: logs each execution
  round, each step run (with type and name), step completion, and
  workflow completion
- WorkflowHost.start() now auto-registers all built-in primitive step
  types so users don't need to register them manually
- Add #[derive(Default)] to all primitive steps and PollEndpointConfig
- Add tracing-subscriber to wfe crate for the pizza example
- Pizza example now shows full step-by-step execution logs
This commit is contained in:
2026-03-25 20:32:47 +00:00
parent 6d57f8ef22
commit 88fc6bf7ad
13 changed files with 70 additions and 3 deletions

View File

@@ -17,6 +17,8 @@ thiserror = { workspace = true }
tracing = { workspace = true }
tokio-util = "0.7"
tracing-subscriber = { workspace = true }
[dev-dependencies]
wfe-core = { workspace = true, features = ["test-support"] }
wfe-sqlite = { workspace = true }

View File

@@ -444,6 +444,13 @@ fn build_pizza_workflow() -> WorkflowDefinition {
#[tokio::main]
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
// Set up tracing so we can see the executor's step-by-step logging.
tracing_subscriber::fmt()
.with_target(false)
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_env_filter("wfe_core=info,wfe=info")
.init();
println!("=== WFE Pizza Workflow Engine Demo ===\n");
// Build the host with in-memory providers (swap for SQLite/Postgres/Valkey in prod)

View File

@@ -33,8 +33,27 @@ pub struct WorkflowHost {
}
impl WorkflowHost {
/// Register all built-in primitive step types.
async fn register_primitives(&self) {
use wfe_core::primitives::*;
let mut sr = self.step_registry.write().await;
sr.register::<decide::DecideStep>();
sr.register::<delay::DelayStep>();
sr.register::<end_step::EndStep>();
sr.register::<foreach_step::ForEachStep>();
sr.register::<if_step::IfStep>();
sr.register::<poll_endpoint::PollEndpointStep>();
sr.register::<recur::RecurStep>();
sr.register::<saga_container::SagaContainerStep>();
sr.register::<schedule::ScheduleStep>();
sr.register::<sequence::SequenceStep>();
sr.register::<wait_for::WaitForStep>();
sr.register::<while_step::WhileStep>();
}
/// Spawn background polling tasks for processing workflows and events.
pub async fn start(&self) -> Result<()> {
self.register_primitives().await;
self.queue_provider.start().await?;
self.lock_provider.start().await?;
if let Some(ref search) = self.search {