ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
workflow_executor Class Referenceabstract

Abstract base for saga workflow executors. More...

#include <workflow_executor.hpp>

Inheritance diagram for workflow_executor:
Inheritance graph
Collaboration diagram for workflow_executor:
Collaboration graph

Public Member Functions

virtual bool execute (ores::database::context ctx, ores::nats::service::nats_client &nats)=0
 Execute all saga steps in order.
 
virtual void compensate (ores::database::context ctx, ores::nats::service::nats_client &nats)=0
 Compensate completed steps in reverse order.
 
virtual const std::string & failure_reason () const =0
 Human-readable reason for a failed execution.
 

Detailed Description

Abstract base for saga workflow executors.

An executor encapsulates one named workflow type. The handler calls execute(); on failure it calls compensate() to roll back completed steps.

Each concrete executor:

The nats_client passed in should already have the end-user JWT set as the delegation token (via nats_client::with_delegation) so that downstream services receive the original caller's context.

Member Function Documentation

◆ execute()

virtual bool execute ( ores::database::context  ctx,
ores::nats::service::nats_client nats 
)
pure virtual

Execute all saga steps in order.

Parameters
ctxPer-request database context for writing step records.
natsAuthenticated NATS client (with delegation) for calling downstream services.
Returns
true on full success; false if any step fails (executor has already stored the error via error()).

Implemented in provision_parties_workflow.

◆ compensate()

virtual void compensate ( ores::database::context  ctx,
ores::nats::service::nats_client nats 
)
pure virtual

Compensate completed steps in reverse order.

Called by the handler when execute() returns false. Must be idempotent.

Parameters
ctxPer-request database context.
natsAuthenticated NATS client (with delegation).

Implemented in provision_parties_workflow.

◆ failure_reason()

virtual const std::string & failure_reason ( ) const
pure virtual

Human-readable reason for a failed execution.

Valid only after execute() returns false.

Implemented in provision_parties_workflow.