Skip to main content

Module task_kind

Module task_kind 

Source
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 POSTs task.webhook_url on 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§

AssignedTask
Bundle of references passed to TaskKind::on_assign so the kind can decide based on the live workflow context without re-querying.
AutoApproveKind
Skip-everything task — used for “checkpoint” steps that exist solely to record progress without blocking on a human.
GroupApprovalKind
Default — a role member must approve via the existing UI.
TaskKindRegistration
Inventory registration shim. Built-in + host-registered kinds land in the same registry via crate::register_task_kind!.
WebhookNotifyKind
Fires a best-effort POST to task.webhook_url and then auto- approves. External systems wire webhook_url to 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§

AssignOutcome
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§

TaskKind
One pluggable workflow task behavior. Defaults make the trait minimal to implement — only Self::kind_name is required; the rest opt in.

Functions§

find
Look up a kind by kind_name. Returns None when missing — the workflow engine falls back to WaitForHuman semantics so an unknown kind doesn’t auto-advance into a corrupt state.
registered_kinds
Every registered task kind, including built-ins.