Knotx / knotx-fragments

Fragments map-reduce processing using Graph flows, supplier and assembler.
https://knotx.io
Apache License 2.0
3 stars 5 forks source link

Behaviours hide doAction details #178

Closed tomaszmichalak closed 4 years ago

tomaszmichalak commented 4 years ago

Is your feature request related to a problem? Please describe. Action is Fragment Operation maker interface that declares a simple function:

void apply(FragmentContext fragmentContext, Handler<AsyncResult<FragmentResult>> resultHandler);

Once an action is created, all internal details are not available until it calls resultHandler and provides configuration details. However, it can throw an exception and then all debug data will be lost.

To prevent this from happening, its configuration is serialized when the action is initialized (io.knotx.fragments.task.factory.generic.node.action.ActionNodeFactory#createActionNodeMetadata). Works great with simple actions, but the problem comes in behaviours.

This is configuration metadata for Circuit Breaker Behaviour:

{
  "alias": "fetch-delivery-options-cb",
  "actionFactory": "cb",
  "actionConfig": {
    "circuitBreakerName": "delivery-cb",
    "circuitBreakerOptions": {
      "maxRetries": 1,
      "timeout": 50
    },
    "logLevel": "error"
  }
}

Behaviours are used to wrap the original action and provide some "behaviour". With such approach we loose details about wrapped action.

Describe the solution you'd like I would like to have details about wrapped action:

{
  "alias": "fetch-delivery-options-cb",
  "actionFactory": "cb",
  "actionConfig": { ... }
  "doAction": {
    "alias": "fetch-delivery-options",
    "actionFactory": "http",
    "actionConfig": { ... }
  }
}

Describe alternatives you've considered Add an additional method to the Action interface that will provide configuration details.

Additional context It impacts Fragment Execution Log:

{
  "operation": {
    "data": {
      "alias": "fetch-delivery-options-cb",
      "actionFactory": "cb",
      "actionConfig": {
        "circuitBreakerName": "delivery-cb",
        "circuitBreakerOptions": {
          "maxRetries": 1,
          "timeout": 50
        },
        "logLevel": "error"
      }
    },
    "factory": "action"
  }
}