├── testing ├── api │ └── testservice │ │ ├── GPBMetadata │ │ └── Temporal │ │ │ └── Api │ │ │ └── Testservice │ │ │ └── V1 │ │ │ ├── Service.php │ │ │ └── RequestResponse.php │ │ └── Temporal │ │ └── Api │ │ └── Testservice │ │ └── V1 │ │ ├── SleepResponse.php │ │ ├── LockTimeSkippingRequest.php │ │ ├── LockTimeSkippingResponse.php │ │ ├── UnlockTimeSkippingRequest.php │ │ └── UnlockTimeSkippingResponse.php └── src │ ├── Replay │ └── Exception │ │ ├── RPCException.php │ │ ├── InternalServerException.php │ │ ├── InvalidArgumentException.php │ │ ├── NonDeterministicWorkflowException.php │ │ └── ReplayerException.php │ ├── WithoutTimeSkipping.php │ ├── WorkflowTestCase.php │ └── ActivityMocker.php ├── src ├── include.php ├── Client │ ├── Schedule │ │ ├── Action │ │ │ └── ScheduleAction.php │ │ ├── Update │ │ │ └── ScheduleUpdateInput.php │ │ └── Info │ │ │ └── ScheduleActionResult.php │ ├── CountWorkflowExecutions.php │ ├── ServerCapabilities.php │ ├── Workflow │ │ ├── CountWorkflowExecutions.php │ │ └── WorkflowExecutionDescription.php │ ├── Common │ │ └── ClientContextInterface.php │ ├── GRPC │ │ ├── Connection │ │ │ └── ConnectionInterface.php │ │ └── ContextInterface.php │ ├── Interceptor │ │ └── SystemInfoInterceptor.php │ └── Update │ │ └── WaitPolicy.php ├── Common │ ├── SearchAttributes │ │ ├── SearchAttributeUpdate │ │ │ ├── ValueUnset.php │ │ │ └── ValueSet.php │ │ ├── ValueType.php │ │ ├── SearchAttributeKey │ │ │ ├── IntValue.php │ │ │ ├── BoolValue.php │ │ │ ├── FloatValue.php │ │ │ ├── TextValue.php │ │ │ ├── KeywordValue.php │ │ │ ├── KeywordListValue.php │ │ │ └── DatetimeValue.php │ │ └── SearchAttributeUpdate.php │ ├── WorkerVersionStamp.php │ ├── SdkVersion.php │ ├── TaskQueue │ │ └── TaskQueue.php │ └── WorkflowIdConflictPolicy.php ├── Activity │ ├── ActivityOptionsInterface.php │ ├── ActivityCancellationDetails.php │ ├── ActivityType.php │ └── ActivityMethod.php ├── Exception │ ├── MarshallerException.php │ ├── ProtocolException.php │ ├── TransportException.php │ ├── IllegalStateException.php │ ├── OutOfContextException.php │ ├── DataConverterException.php │ ├── InstantiationException.php │ ├── InvalidArgumentException.php │ ├── Client │ │ ├── WorkflowQueryException.php │ │ ├── WorkflowServiceException.php │ │ ├── WorkflowNotFoundException.php │ │ ├── ActivityCanceledException.php │ │ ├── ActivityNotExistsException.php │ │ ├── ActivityWorkerShutdownException.php │ │ ├── ActivityCompletionFailureException.php │ │ ├── CanceledException.php │ │ ├── TimeoutException.php │ │ ├── ActivityPausedException.php │ │ ├── WorkflowExecutionAlreadyStartedException.php │ │ ├── WorkflowUpdateException.php │ │ ├── WorkflowUpdateRPCTimeoutOrCanceledException.php │ │ ├── MultyOperation │ │ │ └── OperationStatus.php │ │ ├── UnpackDetailsTrait.php │ │ └── WorkflowQueryRejectedException.php │ ├── FailedCancellationException.php │ ├── Failure │ │ ├── TerminatedFailure.php │ │ ├── ApplicationErrorCategory.php │ │ ├── ServerFailure.php │ │ └── CanceledFailure.php │ ├── DestructMemorizedInstanceException.php │ ├── ExceptionInterceptorInterface.php │ ├── DoNotCompleteOnResultException.php │ ├── CompensationException.php │ └── ExceptionInterceptor.php ├── Worker │ ├── Transport │ │ ├── Command │ │ │ ├── ResponseInterface.php │ │ │ ├── FailureResponseInterface.php │ │ │ ├── CommandInterface.php │ │ │ ├── ServerResponseInterface.php │ │ │ ├── SuccessResponseInterface.php │ │ │ ├── Server │ │ │ │ ├── TickInfo.php │ │ │ │ ├── ServerResponse.php │ │ │ │ ├── FailureResponse.php │ │ │ │ └── SuccessResponse.php │ │ │ ├── Client │ │ │ │ ├── FailedClientResponse.php │ │ │ │ └── SuccessClientResponse.php │ │ │ ├── Common │ │ │ │ └── RequestTrait.php │ │ │ ├── ServerRequestInterface.php │ │ │ └── RequestInterface.php │ │ ├── RPCConnectionInterface.php │ │ ├── CommandBatch.php │ │ ├── HostConnectionInterface.php │ │ └── Codec │ │ │ └── CodecInterface.php │ ├── Environment │ │ ├── EnvironmentInterface.php │ │ └── Environment.php │ ├── DispatcherInterface.php │ ├── ChildWorkflowCancellationType.php │ ├── Logger │ │ └── StderrLogger.php │ ├── ActivityInvocationCache │ │ ├── ActivityInvocationCacheInterface.php │ │ └── ActivityInvocationFailure.php │ ├── WorkflowPanicPolicy.php │ └── ServiceCredentials.php ├── Internal │ ├── Declaration │ │ ├── ActivityInstanceInterface.php │ │ ├── InstanceInterface.php │ │ ├── Graph │ │ │ └── NodeInterface.php │ │ ├── Prototype │ │ │ ├── QueryDefinition.php │ │ │ ├── WorkflowCollection.php │ │ │ ├── SignalDefinition.php │ │ │ ├── UpdateDefinition.php │ │ │ ├── ActivityCollection.php │ │ │ └── PrototypeInterface.php │ │ ├── Dispatcher │ │ │ └── DispatcherInterface.php │ │ ├── WorkflowInstance │ │ │ ├── SignalQueueItem.php │ │ │ ├── SignalMethod.php │ │ │ ├── QueryMethod.php │ │ │ └── UpdateMethod.php │ │ ├── ActivityInstance.php │ │ ├── Instantiator │ │ │ ├── Instantiator.php │ │ │ ├── InstantiatorInterface.php │ │ │ └── ActivityInstantiator.php │ │ ├── Reader │ │ │ └── RecursiveAttributeReducerInterface.php │ │ ├── MethodHandler.php │ │ └── WorkflowInstanceInterface.php │ ├── Promise │ │ └── RejectedValue.php │ ├── Marshaller │ │ ├── Type │ │ │ ├── DetectableTypeInterface.php │ │ │ ├── RuleFactoryInterface.php │ │ │ ├── ActivityCancellationType.php │ │ │ ├── ChildWorkflowCancellationType.php │ │ │ └── TypeInterface.php │ │ ├── Mapper │ │ │ ├── MapperFactoryInterface.php │ │ │ ├── MapperInterface.php │ │ │ └── AttributeMapperFactory.php │ │ ├── RuleFactoryInterface.php │ │ ├── TypeFactoryInterface.php │ │ ├── MarshallerInterface.php │ │ ├── MarshallingRule.php │ │ └── Meta │ │ │ ├── MarshalOneOf.php │ │ │ ├── MarshalNullable.php │ │ │ ├── MarshalAssocArray.php │ │ │ └── MarshalArray.php │ ├── Interceptor │ │ ├── Interceptor.php │ │ └── HeaderCarrier.php │ ├── Transport │ │ ├── Router │ │ │ ├── InvokeLocalActivity.php │ │ │ ├── RouteInterface.php │ │ │ ├── StackTrace.php │ │ │ ├── Route.php │ │ │ ├── WorkflowProcessAwareRoute.php │ │ │ └── CancelWorkflow.php │ │ ├── CompletableResultInterface.php │ │ ├── Request │ │ │ ├── SideEffect.php │ │ │ ├── UpsertMemo.php │ │ │ ├── Panic.php │ │ │ ├── UndefinedResponse.php │ │ │ ├── UpsertSearchAttributes.php │ │ │ ├── CompleteWorkflow.php │ │ │ ├── GetChildWorkflowExecution.php │ │ │ ├── Cancel.php │ │ │ ├── SignalExternalWorkflow.php │ │ │ └── CancelExternalWorkflow.php │ │ ├── ServerInterface.php │ │ └── RouterInterface.php │ ├── Repository │ │ └── Identifiable.php │ ├── Events │ │ ├── EventEmitterInterface.php │ │ ├── EventListenerInterface.php │ │ └── EventEmitterTrait.php │ ├── Exception │ │ └── UndefinedRequestException.php │ ├── Queue │ │ └── QueueInterface.php │ ├── Traits │ │ └── CloneWith.php │ ├── Workflow │ │ ├── AwaitOptions.php │ │ ├── Proxy.php │ │ └── ProcessCollection.php │ ├── Support │ │ ├── Process.php │ │ └── Options.php │ └── Client │ │ └── WorkflowRun.php ├── Workflow │ ├── WorkflowExecutionStatus.php │ ├── ProcessInterface.php │ ├── WorkflowType.php │ ├── ExternalWorkflowStubInterface.php │ ├── WorkflowInit.php │ ├── HandlerUnfinishedPolicy.php │ ├── ResetPointInfo.php │ ├── WorkflowExecutionConfig.php │ ├── UpdateContext.php │ ├── WorkflowMethod.php │ ├── WorkflowVersioningBehavior.php │ ├── ActivityStubInterface.php │ ├── TimerOptions.php │ ├── WorkflowInterface.php │ ├── ParentClosePolicy.php │ ├── ReturnType.php │ └── ScopedContextInterface.php ├── Interceptor │ ├── WorkflowClient │ │ ├── UpdateWithStartOutput.php │ │ ├── UpdateRef.php │ │ ├── CancelInput.php │ │ ├── StartUpdateOutput.php │ │ ├── UpdateWithStartInput.php │ │ ├── TerminateInput.php │ │ ├── DescribeInput.php │ │ ├── GetResultInput.php │ │ └── SignalInput.php │ ├── Header.php │ ├── GrpcClientInterceptor.php │ ├── WorkflowOutboundCalls │ │ ├── SideEffectInput.php │ │ ├── AwaitInput.php │ │ ├── UpsertMemoInput.php │ │ ├── CompleteInput.php │ │ ├── UpsertSearchAttributesInput.php │ │ ├── PanicInput.php │ │ ├── UpsertTypedSearchAttributesInput.php │ │ ├── TimerInput.php │ │ ├── GetVersionInput.php │ │ ├── CancelExternalWorkflowInput.php │ │ ├── ContinueAsNewInput.php │ │ ├── AwaitWithTimeoutInput.php │ │ └── ExecuteChildWorkflowInput.php │ ├── PipelineProvider.php │ ├── Trait │ │ └── ActivityInboundInterceptorTrait.php │ ├── SimplePipelineProvider.php │ ├── ActivityInboundInterceptor.php │ ├── ActivityInbound │ │ └── ActivityInput.php │ ├── WorkflowInbound │ │ └── QueryInput.php │ └── HeaderInterface.php └── DataConverter │ ├── Converter.php │ ├── EncodingKeys.php │ ├── Bytes.php │ ├── DataConverterInterface.php │ ├── PayloadConverterInterface.php │ ├── NullConverter.php │ └── ValuesInterface.php ├── resources └── collections.meta-storm.xml └── LICENSE.md /testing/api/testservice/GPBMetadata/Temporal/Api/Testservice/V1/Service.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/temporalio/sdk-php/HEAD/testing/api/testservice/GPBMetadata/Temporal/Api/Testservice/V1/Service.php -------------------------------------------------------------------------------- /testing/api/testservice/GPBMetadata/Temporal/Api/Testservice/V1/RequestResponse.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/temporalio/sdk-php/HEAD/testing/api/testservice/GPBMetadata/Temporal/Api/Testservice/V1/RequestResponse.php -------------------------------------------------------------------------------- /src/include.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface NodeInterface extends \Stringable, \IteratorAggregate, \Countable {} 18 | -------------------------------------------------------------------------------- /src/Internal/Repository/Identifiable.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | final class WorkflowCollection extends ArrayRepository {} 20 | -------------------------------------------------------------------------------- /src/Exception/Failure/TerminatedFailure.php: -------------------------------------------------------------------------------- 1 | workflowType; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Client/Workflow/CountWorkflowExecutions.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | interface ProcessInterface extends CancellationScopeInterface, Identifiable 21 | { 22 | public function getContext(): WorkflowContextInterface; 23 | } 24 | -------------------------------------------------------------------------------- /src/Activity/ActivityCancellationDetails.php: -------------------------------------------------------------------------------- 1 | testService = TestService::create( 14 | \getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233', 15 | ); 16 | $this->testService->lockTimeSkipping(); 17 | parent::setUp(); 18 | } 19 | 20 | protected function tearDown(): void 21 | { 22 | $this->testService->unlockTimeSkipping(); 23 | parent::tearDown(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Internal/Declaration/Dispatcher/DispatcherInterface.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | public function getArgumentTypes(): array; 25 | } 26 | -------------------------------------------------------------------------------- /src/Exception/Client/ActivityPausedException.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 13 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Internal/Declaration/WorkflowInstance/SignalQueueItem.php: -------------------------------------------------------------------------------- 1 | 19 | * @yield T 20 | */ 21 | interface CompletableResultInterface extends PromiseInterface 22 | { 23 | public function isComplete(): bool; 24 | 25 | /** 26 | * @return mixed 27 | */ 28 | public function getValue(); 29 | } 30 | -------------------------------------------------------------------------------- /src/Workflow/ExternalWorkflowStubInterface.php: -------------------------------------------------------------------------------- 1 | prepareValueSet($value); 19 | } 20 | 21 | public function getType(): ValueType 22 | { 23 | return ValueType::Int; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Internal/Declaration/ActivityInstance.php: -------------------------------------------------------------------------------- 1 | prepareValueSet($value); 19 | } 20 | 21 | public function getType(): ValueType 22 | { 23 | return ValueType::Bool; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Worker/Logger/StderrLogger.php: -------------------------------------------------------------------------------- 1 | format('Y-m-d H:i:s'), 19 | $level, 20 | $message, 21 | $context === [] ? '' : ' ' . (string) \json_encode($context, \JSON_INVALID_UTF8_IGNORE), 22 | )); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Workflow/WorkflowInit.php: -------------------------------------------------------------------------------- 1 | prepareValueSet($value); 19 | } 20 | 21 | public function getType(): ValueType 22 | { 23 | return ValueType::Float; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/UpdateRef.php: -------------------------------------------------------------------------------- 1 | $memo 15 | */ 16 | public function __construct( 17 | private readonly array $memo, 18 | ) { 19 | parent::__construct(self::NAME, ['memo' => (object) $memo]); 20 | } 21 | 22 | /** 23 | * @return array 24 | */ 25 | public function getMemo(): array 26 | { 27 | return $this->memo; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Common/SearchAttributes/SearchAttributeKey/TextValue.php: -------------------------------------------------------------------------------- 1 | prepareValueSet((string) $value); 19 | } 20 | 21 | public function getType(): ValueType 22 | { 23 | return ValueType::Text; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Internal/Transport/Request/Panic.php: -------------------------------------------------------------------------------- 1 | setFailure($failure); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Exception/Failure/ApplicationErrorCategory.php: -------------------------------------------------------------------------------- 1 | prepareValueSet((string) $value); 19 | } 20 | 21 | public function getType(): ValueType 22 | { 23 | return ValueType::Keyword; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/DataConverter/Converter.php: -------------------------------------------------------------------------------- 1 | setMetadata([EncodingKeys::METADATA_ENCODING_KEY => $this->getEncodingType()]); 22 | $payload->setData($data); 23 | 24 | return $payload; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Internal/Declaration/Instantiator/Instantiator.php: -------------------------------------------------------------------------------- 1 | getClass()->newInstance(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testing/src/WorkflowTestCase.php: -------------------------------------------------------------------------------- 1 | workflowClient = new WorkflowClient(ServiceClient::create($temporalAddress)); 20 | $this->testingService = TestService::create($temporalAddress); 21 | 22 | parent::setUp(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Worker/Transport/CommandBatch.php: -------------------------------------------------------------------------------- 1 | messages = $messages; 25 | $this->context = $context; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Exception/Client/WorkflowExecutionAlreadyStartedException.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | interface QueueInterface extends \IteratorAggregate, \Countable 20 | { 21 | public function push(CommandInterface $command): void; 22 | 23 | public function pull(int $commandId): ?CommandInterface; 24 | 25 | public function has(int $commandId): bool; 26 | } 27 | -------------------------------------------------------------------------------- /src/Internal/Traits/CloneWith.php: -------------------------------------------------------------------------------- 1 | newInstanceWithoutConstructor(); 18 | $new->{$key} = $value; 19 | /** @psalm-suppress RawObjectIteration */ 20 | foreach ($this as $k => $v) { 21 | if ($k === $key) { 22 | continue; 23 | } 24 | 25 | $new->{$k} = $v; 26 | } 27 | return $new; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/TypeFactoryInterface.php: -------------------------------------------------------------------------------- 1 | $type 20 | */ 21 | public function create(string $type, array $args): ?TypeInterface; 22 | 23 | /** 24 | * @return class-string|null 25 | */ 26 | public function detect(?\ReflectionType $type): ?string; 27 | } 28 | -------------------------------------------------------------------------------- /src/Internal/Transport/Request/UndefinedResponse.php: -------------------------------------------------------------------------------- 1 | $message]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Internal/Transport/Router/RouteInterface.php: -------------------------------------------------------------------------------- 1 | $this->toPayloadArray()]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Exception/CompensationException.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | private array $suppressed = []; 20 | 21 | public function addSuppressed(\Throwable $e): void 22 | { 23 | $this->suppressed[] = $e; 24 | } 25 | 26 | /** 27 | * @return \Throwable[] 28 | */ 29 | public function getSuppressed(): array 30 | { 31 | return $this->suppressed; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Internal/Transport/ServerInterface.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | interface RuleFactoryInterface extends TypeInterface 22 | { 23 | /** 24 | * Make a marshalling rule for the given property. 25 | */ 26 | public static function makeRule(\ReflectionProperty $property): ?MarshallingRule; 27 | } 28 | -------------------------------------------------------------------------------- /src/Workflow/HandlerUnfinishedPolicy.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | public function getGetters(): iterable; 26 | 27 | /** 28 | * @return iterable 29 | */ 30 | public function getSetters(): iterable; 31 | } 32 | -------------------------------------------------------------------------------- /src/Internal/Transport/Router/StackTrace.php: -------------------------------------------------------------------------------- 1 | findProcessOrFail($request->getID()); 23 | 24 | $context = $process->getContext(); 25 | 26 | $resolver->resolve(EncodedValues::fromValues([$context->getStackTrace()])); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Internal/Declaration/WorkflowInstance/QueryMethod.php: -------------------------------------------------------------------------------- 1 | $searchAttributes 15 | */ 16 | public function __construct( 17 | private readonly array $searchAttributes, 18 | ) { 19 | parent::__construct(self::NAME, ['searchAttributes' => (object) $searchAttributes]); 20 | } 21 | 22 | /** 23 | * @return array 24 | */ 25 | public function getSearchAttributes(): array 26 | { 27 | return $this->searchAttributes; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Internal/Transport/Request/CompleteWorkflow.php: -------------------------------------------------------------------------------- 1 | setFailure($failure); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/Server/TickInfo.php: -------------------------------------------------------------------------------- 1 | $historyLength 18 | * @param int<0, max> $historySize 19 | */ 20 | public function __construct( 21 | public readonly \DateTimeInterface $time, 22 | public readonly int $historyLength = 0, 23 | public readonly int $historySize = 0, 24 | public readonly bool $continueAsNewSuggested = false, 25 | public readonly bool $isReplaying = false, 26 | ) {} 27 | } 28 | -------------------------------------------------------------------------------- /src/Workflow/ResetPointInfo.php: -------------------------------------------------------------------------------- 1 | > $metadata 27 | */ 28 | public function withMetadata(array $metadata): static; 29 | } 30 | -------------------------------------------------------------------------------- /src/Internal/Workflow/AwaitOptions.php: -------------------------------------------------------------------------------- 1 | nonRetryable = $nonRetryable; 26 | } 27 | 28 | public function isNonRetryable(): bool 29 | { 30 | return $this->nonRetryable; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Internal/Declaration/Prototype/ActivityCollection.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | final class ActivityCollection extends ArrayRepository 20 | { 21 | private ?\Closure $finalizer = null; 22 | 23 | public function addFinalizer(\Closure $finalizer): void 24 | { 25 | $this->finalizer = $finalizer; 26 | } 27 | 28 | public function getFinalizer(): ?\Closure 29 | { 30 | return $this->finalizer; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/Server/ServerResponse.php: -------------------------------------------------------------------------------- 1 | id; 26 | } 27 | 28 | public function getTickInfo(): TickInfo 29 | { 30 | return $this->info; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Client/GRPC/Connection/ConnectionInterface.php: -------------------------------------------------------------------------------- 1 | data = $data; 21 | } 22 | 23 | public function getSize(): int 24 | { 25 | return \strlen($this->data); 26 | } 27 | 28 | public function getData(): string 29 | { 30 | return $this->data; 31 | } 32 | 33 | /** 34 | * @return string 35 | */ 36 | public function __toString() 37 | { 38 | return $this->data; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Interceptor/GrpcClientInterceptor.php: -------------------------------------------------------------------------------- 1 | getShortClassName(); 22 | } 23 | 24 | /** 25 | * @return non-empty-string 26 | */ 27 | private function getShortClassName(): string 28 | { 29 | /** @var non-empty-list $chunks */ 30 | $chunks = \explode('\\', static::class); 31 | 32 | return \array_pop($chunks); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/Server/FailureResponse.php: -------------------------------------------------------------------------------- 1 | failure; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/SideEffectInput.php: -------------------------------------------------------------------------------- 1 | callable, 32 | ); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/MarshallerInterface.php: -------------------------------------------------------------------------------- 1 | id; 26 | } 27 | 28 | public function getFailure(): \Throwable 29 | { 30 | return $this->failure; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Internal/Declaration/Reader/RecursiveAttributeReducerInterface.php: -------------------------------------------------------------------------------- 1 | $interceptorClass Only interceptors of this type will be returned in pipeline. 29 | * 30 | * @return Pipeline 31 | */ 32 | public function getPipeline(string $interceptorClass): Pipeline; 33 | } 34 | -------------------------------------------------------------------------------- /src/Internal/Declaration/Prototype/PrototypeInterface.php: -------------------------------------------------------------------------------- 1 | reader = $reader; 24 | } 25 | 26 | public function create(\ReflectionClass $class, TypeFactoryInterface $types): MapperInterface 27 | { 28 | return new AttributeMapper($class, $types, $this->reader); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Internal/Support/Process.php: -------------------------------------------------------------------------------- 1 | run(); 28 | 29 | if (!$process->isSuccessful()) { 30 | throw new ProcessFailedException($process); 31 | } 32 | 33 | return \trim($process->getOutput()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Worker/Transport/HostConnectionInterface.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | interface HostConnectionInterface 20 | { 21 | /** 22 | * @throws TransportException 23 | */ 24 | public function waitBatch(): ?CommandBatch; 25 | 26 | /** 27 | * @param non-empty-string $frame 28 | * @throws TransportException 29 | */ 30 | public function send(string $frame): void; 31 | 32 | /** 33 | * @throws TransportException 34 | */ 35 | public function error(\Throwable $error): void; 36 | } 37 | -------------------------------------------------------------------------------- /src/Worker/WorkflowPanicPolicy.php: -------------------------------------------------------------------------------- 1 | $conditions 20 | */ 21 | public function __construct( 22 | public readonly array $conditions, 23 | ) {} 24 | 25 | /** 26 | * @param array $conditions 27 | */ 28 | public function with( 29 | ?array $conditions = null, 30 | ): self { 31 | return new self( 32 | $conditions ?? $this->conditions, 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Common/SdkVersion.php: -------------------------------------------------------------------------------- 1 | $value 18 | */ 19 | public function valueSet(array $value): SearchAttributeUpdate 20 | { 21 | $values = []; 22 | foreach ($value as $v) { 23 | $values[] = (string) $v; 24 | } 25 | 26 | return $this->prepareValueSet($values); 27 | } 28 | 29 | public function getType(): ValueType 30 | { 31 | return ValueType::KeywordList; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/UpsertMemoInput.php: -------------------------------------------------------------------------------- 1 | $memo 21 | * 22 | * @no-named-arguments 23 | * @internal Don't use the constructor. Use {@see self::with()} instead. 24 | */ 25 | public function __construct( 26 | public readonly array $memo, 27 | ) {} 28 | 29 | public function with( 30 | ?array $memo = null, 31 | ): self { 32 | return new self( 33 | $memo ?? $this->memo, 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Type/ActivityCancellationType.php: -------------------------------------------------------------------------------- 1 | 14 | * @internal 15 | */ 16 | final class ActivityCancellationType extends Type 17 | { 18 | public function parse($value, $current): int 19 | { 20 | return $value ? Policy::WAIT_CANCELLATION_COMPLETED : Policy::TRY_CANCEL; 21 | } 22 | 23 | public function serialize($value): bool 24 | { 25 | return match ($value) { 26 | Policy::WAIT_CANCELLATION_COMPLETED => true, 27 | Policy::TRY_CANCEL => false, 28 | default => throw new \InvalidArgumentException("Option #{$value} is currently not supported"), 29 | }; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/Client/SuccessClientResponse.php: -------------------------------------------------------------------------------- 1 | id; 27 | } 28 | 29 | public function getPayloads(): ValuesInterface 30 | { 31 | return $this->values; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /testing/api/testservice/Temporal/Api/Testservice/V1/SleepResponse.php: -------------------------------------------------------------------------------- 1 | temporal.api.testservice.v1.SleepResponse 13 | */ 14 | class SleepResponse extends \Google\Protobuf\Internal\Message 15 | { 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param array $data { 21 | * Optional. Data for populating the Message object. 22 | * 23 | * } 24 | */ 25 | public function __construct($data = NULL) { 26 | \GPBMetadata\Temporal\Api\Testservice\V1\RequestResponse::initOnce(); 27 | parent::__construct($data); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/CancelInput.php: -------------------------------------------------------------------------------- 1 | workflowExecution, 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Type/ChildWorkflowCancellationType.php: -------------------------------------------------------------------------------- 1 | 15 | * @internal 16 | */ 17 | final class ChildWorkflowCancellationType extends Type 18 | { 19 | public function parse($value, $current): int 20 | { 21 | return $value ? Policy::WAIT_CANCELLATION_COMPLETED : Policy::TRY_CANCEL; 22 | } 23 | 24 | public function serialize($value): bool 25 | { 26 | return match ($value) { 27 | Policy::WAIT_CANCELLATION_COMPLETED => true, 28 | Policy::TRY_CANCEL => false, 29 | default => throw new \InvalidArgumentException("Option #{$value} is currently not supported"), 30 | }; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Worker/ActivityInvocationCache/ActivityInvocationFailure.php: -------------------------------------------------------------------------------- 1 | */ 10 | public string $errorClass; 11 | 12 | public string $errorMessage; 13 | 14 | /** 15 | * @param class-string<\Throwable> $exceptionClass 16 | */ 17 | public function __construct( 18 | string $exceptionClass, 19 | string $exceptionMessage, 20 | ) { 21 | $this->errorClass = $exceptionClass; 22 | $this->errorMessage = $exceptionMessage; 23 | } 24 | 25 | public static function fromThrowable(\Throwable $error): self 26 | { 27 | return new self($error::class, $error->getMessage()); 28 | } 29 | 30 | public function toThrowable(): \Throwable 31 | { 32 | return new ($this->errorClass)($this->errorMessage); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Type/TypeInterface.php: -------------------------------------------------------------------------------- 1 | $marshaller 23 | */ 24 | public function __construct(MarshallerInterface $marshaller); 25 | 26 | /** 27 | * @param mixed $value 28 | * @param mixed $current 29 | * @return mixed 30 | */ 31 | public function parse($value, $current); 32 | 33 | /** 34 | * @param mixed $value 35 | * @return TMarshalType 36 | */ 37 | public function serialize($value); 38 | } 39 | -------------------------------------------------------------------------------- /src/Interceptor/Trait/ActivityInboundInterceptorTrait.php: -------------------------------------------------------------------------------- 1 | temporal.api.testservice.v1.LockTimeSkippingRequest 13 | */ 14 | class LockTimeSkippingRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param array $data { 21 | * Optional. Data for populating the Message object. 22 | * 23 | * } 24 | */ 25 | public function __construct($data = NULL) { 26 | \GPBMetadata\Temporal\Api\Testservice\V1\RequestResponse::initOnce(); 27 | parent::__construct($data); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Internal/Transport/Request/GetChildWorkflowExecution.php: -------------------------------------------------------------------------------- 1 | parentClosePolicy = $execution->getOptions()['options']['ParentClosePolicy'] ?? ParentClosePolicy::POLICY_UNSPECIFIED; 27 | parent::__construct(self::NAME, ['id' => $execution->getID()]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testing/api/testservice/Temporal/Api/Testservice/V1/LockTimeSkippingResponse.php: -------------------------------------------------------------------------------- 1 | temporal.api.testservice.v1.LockTimeSkippingResponse 13 | */ 14 | class LockTimeSkippingResponse extends \Google\Protobuf\Internal\Message 15 | { 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param array $data { 21 | * Optional. Data for populating the Message object. 22 | * 23 | * } 24 | */ 25 | public function __construct($data = NULL) { 26 | \GPBMetadata\Temporal\Api\Testservice\V1\RequestResponse::initOnce(); 27 | parent::__construct($data); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /testing/api/testservice/Temporal/Api/Testservice/V1/UnlockTimeSkippingRequest.php: -------------------------------------------------------------------------------- 1 | temporal.api.testservice.v1.UnlockTimeSkippingRequest 13 | */ 14 | class UnlockTimeSkippingRequest extends \Google\Protobuf\Internal\Message 15 | { 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param array $data { 21 | * Optional. Data for populating the Message object. 22 | * 23 | * } 24 | */ 25 | public function __construct($data = NULL) { 26 | \GPBMetadata\Temporal\Api\Testservice\V1\RequestResponse::initOnce(); 27 | parent::__construct($data); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/StartUpdateOutput.php: -------------------------------------------------------------------------------- 1 | reference; 27 | } 28 | 29 | public function hasResult(): bool 30 | { 31 | return $this->hasResult; 32 | } 33 | 34 | public function getResult(): ?ValuesInterface 35 | { 36 | return $this->result; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /testing/api/testservice/Temporal/Api/Testservice/V1/UnlockTimeSkippingResponse.php: -------------------------------------------------------------------------------- 1 | temporal.api.testservice.v1.UnlockTimeSkippingResponse 13 | */ 14 | class UnlockTimeSkippingResponse extends \Google\Protobuf\Internal\Message 15 | { 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param array $data { 21 | * Optional. Data for populating the Message object. 22 | * 23 | * } 24 | */ 25 | public function __construct($data = NULL) { 26 | \GPBMetadata\Temporal\Api\Testservice\V1\RequestResponse::initOnce(); 27 | parent::__construct($data); 28 | } 29 | 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Common/TaskQueue/TaskQueue.php: -------------------------------------------------------------------------------- 1 | name = $name; 24 | } 25 | 26 | public static function new(string $name): self 27 | { 28 | return new self($name); 29 | } 30 | 31 | public function withName(string $name): self 32 | { 33 | /** @see self::$name */ 34 | return $this->cloneWith('name', $name); 35 | } 36 | 37 | public function __toString(): string 38 | { 39 | return $this->name; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/CompleteInput.php: -------------------------------------------------------------------------------- 1 | result, 34 | $failure ?? $this->failure, 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/Common/RequestTrait.php: -------------------------------------------------------------------------------- 1 | name; 16 | } 17 | 18 | public function getOptions(): array 19 | { 20 | return $this->options; 21 | } 22 | 23 | public function getPayloads(): ValuesInterface 24 | { 25 | return $this->payloads; 26 | } 27 | 28 | public function getHeader(): Header 29 | { 30 | return $this->header; 31 | } 32 | 33 | /** 34 | * @psalm-external-mutation-free 35 | */ 36 | public function withHeader(HeaderInterface $header): self 37 | { 38 | $clone = clone $this; 39 | $clone->header = $header; 40 | return $clone; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Internal/Transport/Request/Cancel.php: -------------------------------------------------------------------------------- 1 | requestIds = $requestId; 31 | parent::__construct(self::NAME, ['ids' => $requestId]); 32 | } 33 | 34 | /** 35 | * @return int[] ID list 36 | */ 37 | public function getRequestIds(): array 38 | { 39 | return $this->requestIds; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/UpsertSearchAttributesInput.php: -------------------------------------------------------------------------------- 1 | $searchAttributes 21 | * 22 | * @no-named-arguments 23 | * @internal Don't use the constructor. Use {@see self::with()} instead. 24 | */ 25 | public function __construct( 26 | public readonly array $searchAttributes, 27 | ) {} 28 | 29 | public function with( 30 | ?array $searchAttributes = null, 31 | ): self { 32 | return new self( 33 | $searchAttributes ?? $this->searchAttributes, 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/PanicInput.php: -------------------------------------------------------------------------------- 1 | failure, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Internal/Declaration/Instantiator/ActivityInstantiator.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | final class ActivityInstantiator extends Instantiator 22 | { 23 | public function instantiate(PrototypeInterface $prototype): ActivityInstance 24 | { 25 | \assert($prototype instanceof ActivityPrototype, 'Precondition failed'); 26 | 27 | return new ActivityInstance($prototype, $this->getInstance($prototype)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/Server/SuccessResponse.php: -------------------------------------------------------------------------------- 1 | values = $values ?? EncodedValues::empty(); 25 | parent::__construct(id: $id, info: $info); 26 | } 27 | 28 | public function getPayloads(): ValuesInterface 29 | { 30 | return $this->values; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testing/src/ActivityMocker.php: -------------------------------------------------------------------------------- 1 | cache = $cache ?? RoadRunnerActivityInvocationCache::create(); 17 | } 18 | 19 | public function clear(): void 20 | { 21 | $this->cache->clear(); 22 | } 23 | 24 | public function expectCompletion(string $activityMethodName, $value): void 25 | { 26 | $this->cache->saveCompletion($activityMethodName, $value); 27 | } 28 | 29 | public function expectFailure(string $activityMethodName, \Throwable $error): void 30 | { 31 | $this->cache->saveFailure($activityMethodName, $error); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Internal/Declaration/WorkflowInstance/UpdateMethod.php: -------------------------------------------------------------------------------- 1 | $prototypes 24 | * @return T|null 25 | */ 26 | protected function findPrototypeByHandlerName(array $prototypes, string $name): ?Prototype 27 | { 28 | foreach ($prototypes as $prototype) { 29 | $handler = $prototype->getHandler(); 30 | 31 | if ($handler->getName() === $name) { 32 | return $prototype; 33 | } 34 | } 35 | 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Workflow/UpdateContext.php: -------------------------------------------------------------------------------- 1 | updateId); 32 | } 33 | 34 | /** 35 | * @return non-empty-string 36 | */ 37 | public function getUpdateId(): string 38 | { 39 | return $this->updateId; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Common/SearchAttributes/SearchAttributeKey/DatetimeValue.php: -------------------------------------------------------------------------------- 1 | prepareValueSet(match (true) { 22 | \is_string($value) => new \DateTimeImmutable($value), 23 | $value instanceof \DateTimeImmutable => $value, 24 | default => \DateTimeImmutable::createFromInterface($value), 25 | }); 26 | } 27 | 28 | public function getType(): ValueType 29 | { 30 | return ValueType::Datetime; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/UpdateWithStartInput.php: -------------------------------------------------------------------------------- 1 | workflowStartInput, 34 | $updateInput ?? $this->updateInput, 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/DataConverter/PayloadConverterInterface.php: -------------------------------------------------------------------------------- 1 | updateId; 32 | } 33 | 34 | public function getUpdateName(): string 35 | { 36 | return $this->updateName; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Common/SearchAttributes/SearchAttributeUpdate.php: -------------------------------------------------------------------------------- 1 | dispatcher = new AutowiredPayloads($reflection); 22 | } 23 | 24 | /** 25 | * Resolve arguments for the method. 26 | */ 27 | public function resolveArguments(ValuesInterface $values): array 28 | { 29 | return $this->dispatcher->resolveArguments($values); 30 | } 31 | 32 | public function __invoke(ValuesInterface $values): mixed 33 | { 34 | $arguments = $this->resolveArguments($values); 35 | return $this->dispatcher->dispatch($this->instance, $arguments); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Internal/Support/Options.php: -------------------------------------------------------------------------------- 1 | diff = new Diff($this); 26 | } 27 | 28 | #[Pure] 29 | public static function new(): static 30 | { 31 | return new static(); 32 | } 33 | 34 | public function __debugInfo(): array 35 | { 36 | $properties = \get_object_vars($this); 37 | unset($properties['diff']); 38 | 39 | $properties['#defaults'] = $this->diff->getDefaultProperties(); 40 | $properties['#changed'] = $this->diff->getChangedProperties($this); 41 | 42 | return $properties; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/TerminateInput.php: -------------------------------------------------------------------------------- 1 | workflowExecution, 36 | $reason ?? $this->reason, 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Worker/Transport/Codec/CodecInterface.php: -------------------------------------------------------------------------------- 1 | $commands 23 | * @return non-empty-string 24 | * 25 | * @throws ProtocolException 26 | */ 27 | public function encode(iterable $commands): string; 28 | 29 | /** 30 | * @return iterable 31 | * 32 | * @throws ProtocolException 33 | */ 34 | public function decode(string $batch, array $headers = []): iterable; 35 | } 36 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/ServerRequestInterface.php: -------------------------------------------------------------------------------- 1 | workflowExecution, 36 | $namespace ?? $this->namespace, 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Interceptor/SimplePipelineProvider.php: -------------------------------------------------------------------------------- 1 | $interceptors 23 | */ 24 | public function __construct( 25 | private iterable $interceptors = [], 26 | ) {} 27 | 28 | public function getPipeline(string $interceptorClass): Pipeline 29 | { 30 | return $this->cache[$interceptorClass] ??= Pipeline::prepare( 31 | \array_filter( 32 | $this->interceptors, 33 | static fn(Interceptor $i): bool => $i instanceof $interceptorClass, 34 | ), 35 | ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Worker/Environment/Environment.php: -------------------------------------------------------------------------------- 1 | tickTime = new \DateTimeImmutable('now', new \DateTimeZone('UTC')); 24 | } 25 | 26 | public function now(): \DateTimeInterface 27 | { 28 | return $this->tickTime; 29 | } 30 | 31 | public function isReplaying(): bool 32 | { 33 | return $this->isReplaying; 34 | } 35 | 36 | public function update(TickInfo $info): void 37 | { 38 | $this->isReplaying = $info->isReplaying; 39 | $this->tickTime = $info->time; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Interceptor/ActivityInboundInterceptor.php: -------------------------------------------------------------------------------- 1 | getPrevious(), 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Interceptor/ActivityInbound/ActivityInput.php: -------------------------------------------------------------------------------- 1 | arguments, 37 | $header ?? $this->header, 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Internal/Workflow/ProcessCollection.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | class ProcessCollection extends ArrayRepository 21 | { 22 | private const ERROR_PROCESS_NOT_FOUND = 'Process #%s not found.'; 23 | 24 | /** 25 | * @param non-empty-string|null $error Error message if the process was not found. 26 | */ 27 | public function pull(string $runId, ?string $error = null): Process 28 | { 29 | $process = $this->find($runId) ?? throw new \InvalidArgumentException( 30 | $error ?? \sprintf(self::ERROR_PROCESS_NOT_FOUND, $runId), 31 | ); 32 | 33 | $this->remove($runId); 34 | 35 | return $process; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/UpsertTypedSearchAttributesInput.php: -------------------------------------------------------------------------------- 1 | $updates 23 | * 24 | * @no-named-arguments 25 | * @internal Don't use the constructor. Use {@see self::with()} instead. 26 | */ 27 | public function __construct( 28 | public readonly array $updates, 29 | ) {} 30 | 31 | /** 32 | * @param array|null $updates 33 | */ 34 | public function with( 35 | ?array $updates = null, 36 | ): self { 37 | return new self( 38 | $updates ?? $this->updates, 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Exception/Failure/CanceledFailure.php: -------------------------------------------------------------------------------- 1 | details = $details ?? EncodedValues::empty(); 26 | } 27 | 28 | public function getDetails(): ValuesInterface 29 | { 30 | return $this->details; 31 | } 32 | 33 | public function setDataConverter(DataConverterInterface $converter): void 34 | { 35 | $this->details->setDataConverter($converter); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Activity/ActivityMethod.php: -------------------------------------------------------------------------------- 1 | name = $name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/TimerInput.php: -------------------------------------------------------------------------------- 1 | interval, 39 | $this->timerOptions, 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/GetVersionInput.php: -------------------------------------------------------------------------------- 1 | changeId, 36 | $minSupported ?? $this->minSupported, 37 | $maxSupported ?? $this->maxSupported, 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/CancelExternalWorkflowInput.php: -------------------------------------------------------------------------------- 1 | namespace, 36 | $workflowId ?? $this->workflowId, 37 | $runId ?? $this->runId, 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/MarshallingRule.php: -------------------------------------------------------------------------------- 1 | |null $type 20 | * @param self|class-string|string|null $of 21 | */ 22 | public function __construct( 23 | public ?string $name = null, 24 | public ?string $type = null, 25 | public self|string|null $of = null, 26 | ) {} 27 | 28 | public function hasType(): bool 29 | { 30 | return $this->type !== null && $this->of !== null; 31 | } 32 | 33 | /** 34 | * Generate constructor arguments for the related {@see \Temporal\Internal\Marshaller\Type\Type} object. 35 | */ 36 | public function getConstructorArgs(): array 37 | { 38 | return $this->of === null ? [] : [$this->of]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Meta/MarshalOneOf.php: -------------------------------------------------------------------------------- 1 | $cases 22 | * @param non-empty-string|null $name 23 | * @param class-string|null $of 24 | */ 25 | public function __construct( 26 | private array $cases, 27 | ?string $name = null, 28 | ?string $of = null, 29 | bool $nullable = true, 30 | ) { 31 | parent::__construct($name, OneOfType::class, $of, $nullable); 32 | } 33 | 34 | public function getConstructorArgs(): array 35 | { 36 | return [$this->of, $this->cases, $this->nullable]; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Workflow/WorkflowMethod.php: -------------------------------------------------------------------------------- 1 | name = $name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Workflow/WorkflowVersioningBehavior.php: -------------------------------------------------------------------------------- 1 | summary = ''; 30 | } 31 | 32 | public static function new(): self 33 | { 34 | return new self(); 35 | } 36 | 37 | /** 38 | * Single-line fixed summary for this timer that will appear in UI/CLI. 39 | * 40 | * This can be in single-line Temporal Markdown format. 41 | */ 42 | public function withSummary(string $summary): self 43 | { 44 | /** @see self::$summary */ 45 | return $this->cloneWith('summary', $summary); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/ContinueAsNewInput.php: -------------------------------------------------------------------------------- 1 | type, 38 | $args ?? $this->args, 39 | $options ?? $this->options, 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/DataConverter/NullConverter.php: -------------------------------------------------------------------------------- 1 | create(''); 34 | } 35 | 36 | /** 37 | * @return null 38 | */ 39 | public function fromPayload(Payload $payload, Type $type) 40 | { 41 | if (!$type->isUntyped() && !$type->allowsNull()) { 42 | throw new DataConverterException('Unable to convert null to non nullable type'); 43 | } 44 | 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowInbound/QueryInput.php: -------------------------------------------------------------------------------- 1 | queryName, 39 | $arguments ?? $this->arguments, 40 | $info ?? $this->info, 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Internal/Events/EventEmitterTrait.php: -------------------------------------------------------------------------------- 1 | 21 | * @template-implements EventListenerInterface 22 | */ 23 | trait EventEmitterTrait 24 | { 25 | /** 26 | * @var array> 27 | */ 28 | protected array $once = []; 29 | 30 | public function once(string $event, callable $then): self 31 | { 32 | $this->once[$event][] = $then; 33 | 34 | return $this; 35 | } 36 | 37 | public function emit(string $event, array $arguments = []): void 38 | { 39 | while (($this->once[$event] ?? []) !== []) { 40 | $callback = \array_shift($this->once[$event]); 41 | $callback(...$arguments); 42 | } 43 | 44 | unset($this->once[$event]); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Common/WorkflowIdConflictPolicy.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | interface HeaderInterface extends \Countable, IteratorAggregate 25 | { 26 | /** 27 | * Checks if any value present. 28 | */ 29 | public function isEmpty(): bool; 30 | 31 | /** 32 | * @param TKey $name 33 | * @param Type|TypeEnum|mixed $type 34 | * 35 | * @return mixed Returns {@see null} if value not found. 36 | */ 37 | public function getValue(int|string $name, mixed $type = null): mixed; 38 | 39 | /** 40 | * @param TKey $name 41 | * @param TValue $value 42 | * 43 | * @psalm-mutation-free 44 | */ 45 | public function withValue(int|string $name, mixed $value): static; 46 | } 47 | -------------------------------------------------------------------------------- /src/Worker/Transport/Command/RequestInterface.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | interface RequestInterface extends CommandInterface 21 | { 22 | public function getID(): int; 23 | 24 | /** 25 | * @return non-empty-string 26 | */ 27 | public function getName(): string; 28 | 29 | /** 30 | * @return RequestOptions 31 | */ 32 | public function getOptions(): array; 33 | 34 | public function getPayloads(): ValuesInterface; 35 | 36 | /** 37 | * Optional failure. 38 | */ 39 | public function getFailure(): ?\Throwable; 40 | 41 | public function getHeader(): HeaderInterface; 42 | 43 | /** 44 | * @psalm-external-mutation-free 45 | */ 46 | public function withHeader(HeaderInterface $header): self; 47 | } 48 | -------------------------------------------------------------------------------- /src/Workflow/WorkflowInterface.php: -------------------------------------------------------------------------------- 1 | $namespace, 34 | 'workflowID' => $workflowId, 35 | 'runID' => $runId, 36 | 'signal' => $signal, 37 | 'childWorkflowOnly' => $childWorkflowOnly, 38 | ]; 39 | 40 | parent::__construct(self::NAME, $options, $input); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Internal/Transport/Router/WorkflowProcessAwareRoute.php: -------------------------------------------------------------------------------- 1 | 25 | */ 26 | protected RepositoryInterface $running, 27 | ) {} 28 | 29 | /** 30 | * @param non-empty-string $runId 31 | */ 32 | protected function findProcessOrFail(string $runId): Process 33 | { 34 | return $this->running->find($runId) ?? throw new UndefinedRequestException( 35 | \sprintf(self::ERROR_PROCESS_NOT_FOUND, $runId), 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Client/Interceptor/SystemInfoInterceptor.php: -------------------------------------------------------------------------------- 1 | serviceClient->getServerCapabilities(); 34 | 35 | return $next($method, $arg, $ctx); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Exception/Client/MultyOperation/OperationStatus.php: -------------------------------------------------------------------------------- 1 | &RepeatedField $details 21 | */ 22 | private function __construct( 23 | private readonly \Traversable $details, 24 | private readonly string $message, 25 | ) {} 26 | 27 | public static function fromMessage(OperationStatusMessage $message): self 28 | { 29 | return new self($message->getDetails(), $message->getMessage()); 30 | } 31 | 32 | public function getMessage(): string 33 | { 34 | return $this->message; 35 | } 36 | 37 | /** 38 | * @return \ArrayAccess&RepeatedField 39 | */ 40 | private function getDetails(): \Traversable 41 | { 42 | return $this->details; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Meta/MarshalNullable.php: -------------------------------------------------------------------------------- 1 | of === null => false, 38 | $this->of instanceof MarshallingRule => $this->of->hasType(), 39 | default => true, 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Client/Schedule/Info/ScheduleActionResult.php: -------------------------------------------------------------------------------- 1 | retryableErrors = $retryableErrors; 25 | } 26 | 27 | /** 28 | * @return static 29 | */ 30 | public static function createDefault(): self 31 | { 32 | return new self([\Error::class]); 33 | } 34 | 35 | public function isRetryable(\Throwable $e): bool 36 | { 37 | foreach ($this->retryableErrors as $retryableError) { 38 | if ($e instanceof $retryableError) { 39 | return true; 40 | } 41 | } 42 | 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Worker/ServiceCredentials.php: -------------------------------------------------------------------------------- 1 | apiKey = ''; 21 | } 22 | 23 | public static function create(): self 24 | { 25 | return new self(); 26 | } 27 | 28 | /** 29 | * Set the authentication token for API calls. 30 | * 31 | * To update the API key in runtime, call the `UpdateAPIKey` RPC method with the new key: 32 | * 33 | * ``` 34 | * $result = \Temporal\Worker\Transport\Goridge::create()->call( 35 | * 'temporal.UpdateAPIKey', 36 | * $newApiKey, 37 | * ); 38 | * ``` 39 | * 40 | * @link https://docs.temporal.io/cloud/api-keys 41 | * @since SDK 2.12.0 42 | * @since RoadRunner 2024.3.0 43 | */ 44 | public function withApiKey(string $key): static 45 | { 46 | /** @see self::$apiKey */ 47 | return $this->cloneWith('apiKey', $key); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Workflow/ParentClosePolicy.php: -------------------------------------------------------------------------------- 1 | lifecycleStage = LifecycleStage::StageUnspecified; 29 | } 30 | 31 | public static function new(): self 32 | { 33 | return new self(); 34 | } 35 | 36 | /** 37 | * Indicates the update lifecycle stage that the gRPC call should wait for before returning. 38 | */ 39 | public function withLifecycleStage(LifecycleStage $value): self 40 | { 41 | /** @see self::$lifecycleStage */ 42 | return $this->cloneWith('lifecycleStage', $value); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Exception/Client/UnpackDetailsTrait.php: -------------------------------------------------------------------------------- 1 | $class 21 | * @return T|null 22 | * @throws \Exception 23 | */ 24 | public function getFailure(string $class): ?object 25 | { 26 | $details = $this->getDetails(); 27 | if ($details->count() === 0) { 28 | return null; 29 | } 30 | 31 | // ensures that message descriptor was added to the pool 32 | Message::initOnce(); 33 | 34 | /** @var Any $detail */ 35 | foreach ($details as $detail) { 36 | if ($detail->is($class)) { 37 | return $detail->unpack(); 38 | } 39 | } 40 | 41 | return null; 42 | } 43 | 44 | /** 45 | * @return \ArrayAccess&RepeatedField 46 | */ 47 | abstract private function getDetails(): iterable; 48 | } 49 | -------------------------------------------------------------------------------- /src/Exception/Client/WorkflowQueryRejectedException.php: -------------------------------------------------------------------------------- 1 | queryRejectCondition = $queryRejectCondition; 30 | $this->workflowExecutionStatus = $workflowExecutionStatus; 31 | } 32 | 33 | public function getQueryRejectCondition(): int 34 | { 35 | return $this->queryRejectCondition; 36 | } 37 | 38 | public function getWorkflowExecutionStatus(): int 39 | { 40 | return $this->workflowExecutionStatus; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowOutboundCalls/AwaitWithTimeoutInput.php: -------------------------------------------------------------------------------- 1 | $conditions 27 | */ 28 | public function __construct( 29 | public readonly \DateInterval $interval, 30 | public readonly array $conditions, 31 | ) {} 32 | 33 | /** 34 | * @param array $conditions 35 | */ 36 | public function with( 37 | ?\DateInterval $interval = null, 38 | ?array $conditions = null, 39 | ): self { 40 | return new self( 41 | $interval ?? $this->interval, 42 | $conditions ?? $this->conditions, 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Workflow/ReturnType.php: -------------------------------------------------------------------------------- 1 | nullable = $nullable || (new Type($name))->allowsNull(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/GetResultInput.php: -------------------------------------------------------------------------------- 1 | workflowExecution, 39 | $workflowType ?? $this->workflowType, 40 | $timeout ?? $this->timeout, 41 | $this->type, 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Interceptor/WorkflowClient/SignalInput.php: -------------------------------------------------------------------------------- 1 | workflowExecution, 39 | $this->workflowType, 40 | $signalName ?? $this->signalName, 41 | $arguments ?? $this->arguments, 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Meta/MarshalAssocArray.php: -------------------------------------------------------------------------------- 1 | $namespace, 30 | 'workflowID' => $workflowId, 31 | 'runID' => $runId, 32 | ]; 33 | 34 | parent::__construct(self::NAME, $options, null); 35 | } 36 | 37 | public function getNamespace(): string 38 | { 39 | return $this->namespace; 40 | } 41 | 42 | public function getWorkflowId(): string 43 | { 44 | return $this->workflowId; 45 | } 46 | 47 | public function getRunId(): ?string 48 | { 49 | return $this->runId; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Internal/Client/WorkflowRun.php: -------------------------------------------------------------------------------- 1 | stub->getExecution(); 33 | } 34 | 35 | public function getResult($type = null, ?int $timeout = null): mixed 36 | { 37 | return $this->stub->getResult($type ?? $this->returnType, $timeout); 38 | } 39 | 40 | public function describe(): WorkflowExecutionDescription 41 | { 42 | return $this->stub->describe(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Internal/Declaration/WorkflowInstanceInterface.php: -------------------------------------------------------------------------------- 1 | ) $handler 26 | * @return CancellationScopeInterface 27 | * 28 | * @see Workflow::async() 29 | */ 30 | public function async(callable $handler): CancellationScopeInterface; 31 | 32 | /** 33 | * Cancellation scope which does not react to parent cancel and completes 34 | * in background. 35 | * 36 | * @template TReturn 37 | * @param callable(): (TReturn|\Generator) $handler 38 | * @return CancellationScopeInterface 39 | * 40 | * @see Workflow::asyncDetached() 41 | */ 42 | public function asyncDetached(callable $handler): CancellationScopeInterface; 43 | } 44 | -------------------------------------------------------------------------------- /src/Client/GRPC/ContextInterface.php: -------------------------------------------------------------------------------- 1 | type, 40 | $args ?? $this->args, 41 | $options ?? $this->options, 42 | $returnType ?? $this->returnType, 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Internal/Marshaller/Meta/MarshalArray.php: -------------------------------------------------------------------------------- 1 | cancel($request->getID()); 26 | 27 | $resolver->resolve(EncodedValues::fromValues([null])); 28 | } 29 | 30 | /** 31 | * @throws UndefinedRequestException 32 | */ 33 | private function cancel(string $runId): void 34 | { 35 | $process = $this->running->find($runId) ?? throw new UndefinedRequestException( 36 | \sprintf(self::ERROR_PROCESS_NOT_DEFINED, $runId), 37 | ); 38 | 39 | $process->cancel(); 40 | } 41 | } 42 | --------------------------------------------------------------------------------