Handling context propagation (headers) with PHP-SDK

Hello,

We’re preparing to replace our SAGA implementation with Temporal. Our application is mainly PHP services. To replace SAGA with TEMPORAL we need headers, but viewing PHP-SDK it’s pretty clear it doesn’t currently support it.
Now it would be nice to use the proper native implementation for headers.

So I’ve tried fiddling with PHP-SDK and found out that I would be able to send the headers to Temporal with StartWorkflowExecutionRequest, but they never get to the PHP workflow worker. It seems RoadRunner itself sends no header data.

What we see in temporal on WorkflowExecutionStarted event.

Example request from RoadRunner to our worker:

[
  {
    "id": 3,
    "command": "StartWorkflow",
    "options": {
      "info": {
        "WorkflowExecution": {
          "ID": "30f994d2-751f-43b1-a12a-2808cc46106d",
          "RunID": "ec553d2f-c11e-4edf-8512-80fdd442d19d"
        },
        "WorkflowType": {
          "Name": "SagaInitiatorWorkflow"
        },
        "TaskQueueName": "saga_command_bus",
        "WorkflowExecutionTimeout": 0,
        "WorkflowRunTimeout": 0,
        "WorkflowTaskTimeout": 10000000000,
        "Namespace": "default",
        "Attempt": 1,
        "WorkflowStartTime": "2021-10-23T17:35:49.803881994Z",
        "CronSchedule": "",
        "ContinuedExecutionRunID": "",
        "ParentWorkflowNamespace": "",
        "ParentWorkflowExecution": null,
        "Memo": {
          "fields": {
            "test": {
              "metadata": {
                "encoding": "anNvbi9wbGFpbg=="
              },
              "data": "InRlc3Qi"
            }
          }
        },
        "SearchAttributes": null,
        "BinaryChecksum": "f0cd8050b1dd03390392baa8937a7ff6"
      }
    },
    "payloads": "...no headers in payload either.."
  }
]

Now the headers are never seen again on any activities or their event records.

I’ve tried in both Protobuf and JSON codecs to no avail.

My questions would be:

  1. Is it something wrong with my configuration? Is it RoadRunner?
  2. If it can’t be fixed by me or anyone else currently, would using Memos to pass our header data cause any serious side effects? I’ve already taken care of the workflow → activity “header” simulation by appending headers to the end of the payload and removing/processing it upon receiving in activity worker.

Hi,

the design of context passing was originally linked to the interceptors’ design, which is still at the design phase at PHP SDK.

However, we will work on prioritizing the access to context metadata and adding needed headers. Our next milestone starts on Nov 1st. We will work on providing access to these properties shortly* after.

JD

1 Like

That’s great news!

Since you guys are more experienced in temporal.

Do you see any drawbacks in using Memos to pass our context headers data in the meantime? Provided that we take care of the Workflow → Activity header data injection. I see no problems going back to proper context passing after it’s implemented in PHP SDK.

This sounds like a hack. I would pass the context as an argument to the workflow.

1 Like

Hey :wave:
That was a bug in the RR-Temporal. I forgot :cry: to pass the headers to the our internal workflow message; you may track the progress in this PR: chore: pass headers to the PHP worker by rustatian · Pull Request #303 · temporalio/roadrunner-temporal · GitHub

1 Like

Thank you! :christmas_tree:

1 Like

Starting from the RR v2.12.2 (not released yet), you’ll be able to send/receive your values via workflow/activity headers.

1 Like