Skip to main content

Processing Fallbacks

Fallbacks are managed using ductape.processor.fallback.run(data) within the Ductape system. This processor allows you to define, trigger, and update fallback logic for products or features when primary actions fail or time out.

await ductape.processor.fallback.run(data: IFallbackProcessorInput)

This processes a fallback event in the specified environment and application context, handling fallback execution or updates.

Parameters

IFallbackProcessorInput

FieldTypeRequiredDescription
envstringYesEnvironment slug (e.g., "dev", "prd").
product_tagstringYesUnique identifier for the product.
fallback_tagstringYesTag of the fallback to trigger or update.
actionstringYesAction to perform: "trigger", "update", or "reset".
inputobjectNoInput data for the fallback logic.
sessionISessionNoAttach user session context to the request.
cachestringNoCache tag to cache this request, if applicable.

Note: Optional fields can be omitted or passed as empty {}.

ISession Schema

The session field enables optional session tracking for any fallback operation.

interface ISession {
tag: string; // session tag
token: string; // session token (e.g. signed JWT)
}
FieldTypeRequiredDescription
tagstringYesTag identifying the session type.
tokenstringYesToken generated when the session was created.

Returns

Returns a Promise<unknown> resolving with the result of the fallback operation. The exact structure depends on the specific fallback action.

Example

const data = {
env: "prd",
product_tag: "my-product",
fallback_tag: "payment-failure",
action: "trigger",
input: {
orderId: "12345",
reason: "timeout"
},
session: {
tag: "user-session",
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
},
cache: "fallback-payment-failure"
};

const res = await ductape.processor.fallback.run(data);

See Also