Skip to content

[Feature Request] Provide a typed result API #788

Description

@knegyesi

Is your feature request related to a problem? Please describe.

I would like to retrieve the result of a workflow run. The workflow method has a return type but this is not taken into account because getResult only exists on the untyped stub as the typed stub is a proxy class to the workflow and calls workflow class methods but the untyped stub doesn't have type info.

Describe the solution you'd like

There should be a higher level API than WorkflowRunInterface::getResult which can infer the type automatically from the return type of the workflow method. Since the return workflow method must be a supertype of Generator this might need the ability to handle composite types, there are multiple type libraries for example symfony/type-info although I have simply done

    $workflowReturnType = $this->temporalFactories
      ->getWorkflowStub($workflowClass)
      ->getHandlerReflection()
      ->getReturnType();
    if ($workflowReturnType instanceof \ReflectionUnionType &&
      ($types = array_diff(array_map('strval', $workflowReturnType->getTypes()), ['Generator']))) {
      return reset($types);
    }

in my workaround to the problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions