Workflow middleware
This is configured on a worker similar to workflow_task and acitvity middleware (worker.add_workflow_middleware(middleware). Workflow middleware gets the workflow metadata which contains headers, and can be used to extract things out of the headers. Activities already have this support via the activity middleware.
Header propagation (inject into outgoing headers)
This is configured on the temporal configuration (c.add_header_propagator(propagator)). The propagator is for outgoing headers- so you want to inject into the headers. A propagator is just a class that implements def inject!(header) that modifies header in place and does not return anything.
Tests have been added/amended as necessary.
The original issue recommended adding metadata to the workflow task but upon closer inspection that was not really feasible and instead was replaced with adding middleware for the workflow.
This change adds the following changes and addresses https://github.com/coinbase/temporal-ruby/issues/225:
Workflow middleware This is configured on a worker similar to workflow_task and acitvity middleware (worker.add_workflow_middleware(middleware). Workflow middleware gets the workflow metadata which contains headers, and can be used to extract things out of the headers. Activities already have this support via the activity middleware.
Header propagation (inject into outgoing headers) This is configured on the temporal configuration (c.add_header_propagator(propagator)). The propagator is for outgoing headers- so you want to inject into the headers. A propagator is just a class that implements
def inject!(header)
that modifies header in place and does not return anything.Tests have been added/amended as necessary.
The original issue recommended adding metadata to the workflow task but upon closer inspection that was not really feasible and instead was replaced with adding middleware for the workflow.