IExecutable

Interface that allows you to create a component that can be called to execute work.

Description

The IExecutable interface allows you to create a component that can be called to execute work.

Instance methods

execute

Executes component with arguments and receives execution result.

execute(correlationId: string, args: Parameters): Promise<any>

  • correlationId: string - (optional) transaction id to trace execution through call chain.
  • args: Parameters - execution arguments.
  • returns: Promise<any> - the execution result.

Examples

class EchoComponent implements IExecutable {
    ...
    public async execute(correlationId: string, args: Parameters): Promise<any> {
        let result = args.getAsObject("message");
        return result;
    }
}
    
let echo = new EchoComponent();
let message = "Test";
let result = await echo.execute("123", Parameters.fromTuples("message", message))
console.log("Request: " + message + " Response: " + result);

See also