Interface DecidingHook<H>

The policy and the step hook whose returned lifecycle decided something. Only step hooks return lifecycles, so only they decide.

import type { DecidedBy, Event, GiveUpHook } from "itinera/event";

function decider(decidedBy: DecidedBy): string {
return decidedBy === "default"
? "by default"
: `by ${decidedBy.policy}, ${decidedBy.hook}`;
}

export function givenUpAfter(hook: GiveUpHook): string {
return hook === "on step retry"
? "before a retry"
: "after an abnormal termination";
}

export function decision(event: Event): string | undefined {
if (event.kind === "step_given_up") {
return `${event.step} given up: ${event.cause}, ${decider(event.decidedBy)}`;
}
if (event.kind === "journey_failed" || event.kind === "journey_succeeded") {
return `${event.kind} ${decider(event.decidedBy)}`;
}
return undefined;
}
interface DecidingHook<H extends StepHook = StepHook> {
    hook: H;
    policy: PolicyName;
}

Type Parameters

Index

hook: H

The hook.

policy: PolicyName

The policy's name.