Expand description
Custom workflow task kinds.
WorkflowTask rows carry a kind discriminator (default
"group_approval" — a role member clicks approve). The
TaskKind trait lets hosts register additional kinds:
auto-approve, webhook-on-assign, or anything else they need.
§Built-in kinds
group_approval— current behavior; a member of the task’s role decides via the editor UI.auto_approve— completes immediately when assigned. Useful for steps that exist only to record a workflow checkpoint (e.g. “schedule final publish” as a no-op separator).webhook_notify— best-effort POSTstask.webhook_urlon assign, then completes the task. External systems can trigger their own approval back via the usual approve endpoint when they’re ready.
§Registering a custom kind
ⓘ
use rustango_cms::task_kind::{TaskKind, TaskKindRegistration, AssignedTask, AssignOutcome};
struct ConditionalSkip;
impl TaskKind for ConditionalSkip {
fn kind_name(&self) -> &'static str { "conditional_skip" }
fn verbose_name(&self) -> &'static str { "Conditional skip" }
fn on_assign(&self, _task: &AssignedTask<'_>) -> AssignOutcome {
// Inspect _task.page / _task.task and decide.
AssignOutcome::AutoApprove
}
}
rustango_cms::register_task_kind!(ConditionalSkip);Structs§
- Assigned
Task - Bundle of references passed to
TaskKind::on_assignso the kind can decide based on the live workflow context without re-querying. - Auto
Approve Kind - Skip-everything task — used for “checkpoint” steps that exist solely to record progress without blocking on a human.
- Group
Approval Kind - Default — a role member must approve via the existing UI.
- Task
Kind Registration - Inventory registration shim. Built-in + host-registered kinds
land in the same registry via
crate::register_task_kind!. - Webhook
Notify Kind - Fires a best-effort POST to
task.webhook_urland then auto- approves. External systems wirewebhook_urlto whatever they want notified (a Slack incoming webhook, a custom orchestrator, the legal team’s intake form). The HTTP fire is intentionally stubbed at the framework level — see the impl for details — so no new HTTP-client dependency is forced on the default build.
Enums§
- Assign
Outcome - Outcome of
TaskKind::on_assign. The workflow engine reads it to decide whether to leave the task in flight (WaitForHuman) or auto-advance (AutoApprove).
Traits§
- Task
Kind - One pluggable workflow task behavior. Defaults make the trait
minimal to implement — only
Self::kind_nameis required; the rest opt in.
Functions§
- find
- Look up a kind by
kind_name. ReturnsNonewhen missing — the workflow engine falls back toWaitForHumansemantics so an unknown kind doesn’t auto-advance into a corrupt state. - registered_
kinds - Every registered task kind, including built-ins.