diff --git a/.run/Psalm.run.xml b/.run/Psalm.run.xml new file mode 100644 index 000000000..6f80a21ce --- /dev/null +++ b/.run/Psalm.run.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b4f8ab725..4060432aa 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,18 @@ If you are using the SDK without integrations, the following sections of the doc - [How to connect a Temporal Client to a Temporal Service](https://docs.temporal.io/develop/php/temporal-clients#connect-to-a-dev-cluster) - [How to start a Workflow Execution](https://docs.temporal.io/develop/php/temporal-clients#start-workflow-execution) +Administrative operator APIs are available through [`Temporal\Client\GRPC\OperatorClient`](https://php.temporal.io/): + +```php +use Temporal\Api\Operatorservice\V1\DeleteNamespaceRequest; +use Temporal\Client\GRPC\OperatorClient; + +$operatorClient = OperatorClient::create('127.0.0.1:7233'); +$response = $operatorClient->DeleteNamespace( + (new DeleteNamespaceRequest())->setNamespace('example-namespace'), +); +``` + > [!NOTE] > Check out [the repository with examples](https://github.com/temporalio/samples-php) of using the PHP SDK. diff --git a/dload.xml b/dload.xml index 0b70f0a64..9e7358aa4 100644 --- a/dload.xml +++ b/dload.xml @@ -6,7 +6,7 @@ - + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 620ba5124..85232877d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -924,10 +924,6 @@ - - - - @@ -1182,12 +1178,6 @@ - - serializeToString()]]> - - - - getCode()]]> getCode()]]> diff --git a/resources/scripts/generate-client.php b/resources/scripts/generate-client.php index 852a49a86..1173466b6 100644 --- a/resources/scripts/generate-client.php +++ b/resources/scripts/generate-client.php @@ -10,40 +10,43 @@ use Grpc\BaseStub; use Laminas\Code\Generator; use Laminas\Code\Generator\MethodGenerator; -use Temporal\Api\Workflowservice; +use Temporal\Api\Operatorservice\V1\OperatorServiceClient; +use Temporal\Api\Workflowservice\V1\WorkflowServiceClient; +use Temporal\Client\GRPC\GrpcClientInterface; use Temporal\Client\Common\ServerCapabilities; -use Temporal\Client\GRPC\Connection\ConnectionInterface; use Temporal\Client\GRPC\ContextInterface; +use Laminas\Code\DeclareStatement; require __DIR__ . '/../../vendor/autoload.php'; -echo "Compiling client...\n"; - -echo "reading client schema: "; - -$r = new ReflectionClass(Workflowservice\V1\WorkflowServiceClient::class); -$rBase = new ReflectionClass(BaseStub::class); +echo "Compiling clients...\n"; $ctxParam = Generator\ParameterGenerator::fromArray( [ - 'type' => \Temporal\Client\GRPC\ContextInterface::class, + 'type' => '?' . ContextInterface::class, 'name' => 'ctx', 'defaultValue' => null, - ] + ], ); - -$methodDocBlock = function (ReflectionClass $r, string $method, string $arg, string $return) { +$addressParam = Generator\ParameterGenerator::fromArray(['type' => 'string', 'name' => 'address']); +$optionsParam = Generator\ParameterGenerator::fromArray(['type' => 'array', 'name' => 'options']); + +$buildMethodDocBlock = static function ( + ReflectionClass $serviceReflection, + string $method, + string $arg, + string $return, +): string { $block = []; - // copy from existing doc block - $orig = $r->getMethod($method)->getDocComment(); - foreach (explode("\n", $orig) as $line) { - $line = trim($line, "\n\r* "); + $original = $serviceReflection->getMethod($method)->getDocComment(); + foreach (\explode("\n", (string) $original) as $line) { + $line = \trim($line, "\n\r* "); if ($line === '/') { continue; } - if (substr($line, 0, 1) === '@') { + if (\str_starts_with($line, '@')) { break; } @@ -51,179 +54,277 @@ } $block[] = ''; - $block[] = sprintf('@param \\%s $arg', $arg); - $block[] = sprintf('@param ContextInterface|null $ctx'); - $block[] = sprintf('@return \\%s', $return); - $block[] = sprintf('@throws ServiceClientException'); + $block[] = '@throws ServiceClientException'; - return join("\n", $block); + return \implode("\n", $block); }; -$methods = []; +$baseStubReflection = new ReflectionClass(BaseStub::class); +$buildRpcMap = static function (ReflectionClass $serviceReflection) use ($baseStubReflection): array { + $methods = []; -// fetching available methods + foreach ($serviceReflection->getMethods() as $method) { + if ($baseStubReflection->hasMethod($method->getName())) { + continue; + } -foreach ($r->getMethods() as $m) { - if ($rBase->hasMethod($m->getName())) { - continue; - } + $request = $method->getParameters()[0]->getType()?->getName(); + $response = $request === null ? null : \substr($request, 0, -7) . 'Response'; - $method = [ - 'request' => null, - 'response' => null, - ]; + \assert($request !== null); + \assert(\class_exists($request)); + \assert(\is_string($response) && \class_exists($response)); - // simple heuristics - $method['request'] = $m->getParameters()[0]->getType()->getName(); - $method['response'] = substr($method['request'], 0, -7) . 'Response'; + $methods[$method->getName()] = [ + 'request' => $request, + 'response' => $response, + ]; + } - assert(class_exists($method['request'])); - assert(class_exists($method['response'])); + return $methods; +}; - $methods[$m->getName()] = $method; -} +$buildCreateServiceClientMethod = static function ( + string $serviceClientFqcn, +) use ($addressParam, $optionsParam): MethodGenerator { + $method = new MethodGenerator( + 'createGrpcStub', + [$addressParam, $optionsParam], + MethodGenerator::FLAG_PROTECTED | MethodGenerator::FLAG_STATIC, + ); + $method->setReturnType('\Grpc\BaseStub'); + $method->setBody(\sprintf('return new \\%s($address, $options);', $serviceClientFqcn)); -echo "[OK]\n"; + return $method; +}; -echo "generating interface: "; +$buildGetServerCapabilitiesInterfaceMethod = static function (): MethodGenerator { + $method = new MethodGenerator('getServerCapabilities'); + $method->setReturnType('?\Temporal\Client\Common\ServerCapabilities'); -$interface = new Generator\InterfaceGenerator('ServiceClientInterface'); + return $method; +}; +$buildGetServerCapabilitiesImplementationMethod = static function (): MethodGenerator { + $method = new MethodGenerator('getServerCapabilities'); + $method->setReturnType('?\Temporal\Client\Common\ServerCapabilities'); + $method->setBody(<<<'PHP' +$connection = $this->getInternalConnection(); +if ($connection->getCapabilities() !== null) { + return $connection->getCapabilities(); +} -// getContext(): ContextInterface -$m = new MethodGenerator( - 'getContext', - [], - MethodGenerator::FLAG_PUBLIC, -); -$m->setReturnType(ContextInterface::class); -$interface->addMethodFromGenerator($m); -// withContext(ContextInterface $context): static -$m = new MethodGenerator( - 'withContext', - [Generator\ParameterGenerator::fromArray(['type' => ContextInterface::class, 'name' => 'context'])], - MethodGenerator::FLAG_PUBLIC, -); -$m->setReturnType('static'); -$interface->addMethodFromGenerator($m); -// withAuthKey(string $key): static -$m = new MethodGenerator( - 'withAuthKey', - [Generator\ParameterGenerator::fromArray(['type' => '\Stringable|string', 'name' => 'key'])], - MethodGenerator::FLAG_PUBLIC, -); -$m->setReturnType('static'); -$interface->addMethodFromGenerator($m); -// public function getConnection(): ConnectionInterface -$m = new MethodGenerator( - 'getConnection', - [], - MethodGenerator::FLAG_PUBLIC, -); -$m->setReturnType(ConnectionInterface::class); -$interface->addMethodFromGenerator($m); -// Add Capability methods -$m = new MethodGenerator( - 'getServerCapabilities', - [], - MethodGenerator::FLAG_PUBLIC, -); -$m->setReturnType('?' . ServerCapabilities::class); -$interface->addMethodFromGenerator($m); +try { + $systemInfo = $this->getSystemInfo(new GetSystemInfoRequest()); + $capabilities = $systemInfo->getCapabilities(); -foreach ($methods as $method => $options) { - $m = new MethodGenerator($method); + if ($capabilities === null) { + return null; + } - $m->setDocBlock(($methodDocBlock)($r, $method, $options['request'], $options['response'])); - $m->setParameters( - [ - Generator\ParameterGenerator::fromArray(['type' => $options['request'], 'name' => 'arg']), - $ctxParam - ] + $serverCapabilities = new ServerCapabilities( + signalAndQueryHeader: $capabilities->getSignalAndQueryHeader(), + internalErrorDifferentiation: $capabilities->getInternalErrorDifferentiation(), + activityFailureIncludeHeartbeat: $capabilities->getActivityFailureIncludeHeartbeat(), + supportsSchedules: $capabilities->getSupportsSchedules(), + encodedFailureAttributes: $capabilities->getEncodedFailureAttributes(), + buildIdBasedVersioning: $capabilities->getBuildIdBasedVersioning(), + upsertMemo: $capabilities->getUpsertMemo(), + eagerWorkflowStart: $capabilities->getEagerWorkflowStart(), + sdkMetadata: $capabilities->getSdkMetadata(), + countGroupByExecutionStatus: $capabilities->getCountGroupByExecutionStatus(), + nexus: $capabilities->getNexus(), ); - $m->setReturnType($options['response']); + $connection->setCapabilities($serverCapabilities); - $interface->addMethodFromGenerator($m); -} + return $serverCapabilities; +} catch (ServiceClientException $e) { + if ($e->getCode() === StatusCode::UNIMPLEMENTED) { + return null; + } -$m = new MethodGenerator( - 'close', - [], - MethodGenerator::FLAG_PUBLIC, - null, - 'Close the communication channel associated with this stub.' -); -$m->setReturnType('void'); -$interface->addMethodFromGenerator($m); + throw $e; +} +PHP); -echo "[OK]\n"; -echo "writing interface: "; + return $method; +}; -$file = new Generator\FileGenerator(); -$file->setNamespace('Temporal\\Client\\GRPC'); -$file->setClass($interface); -$file->setUses( - [ - 'Temporal\Api\Workflowservice\V1', - 'Temporal\Exception\Client\ServiceClientException', - ] +$buildSetServerCapabilitiesMethod = static function (): MethodGenerator { + $method = new MethodGenerator( + 'setServerCapabilities', + [Generator\ParameterGenerator::fromArray(['type' => '\Temporal\Client\Common\ServerCapabilities', 'name' => 'capabilities'])], + ); + $method->setReturnType('void'); + $method->setBody(<<<'PHP' +\trigger_error( + 'Method ' . __METHOD__ . ' is deprecated and will be removed in the next major release.', + \E_USER_DEPRECATED, ); -// write and shorten names -file_put_contents( - __DIR__ . '/../../src/Client/GRPC/ServiceClientInterface.php', - str_replace( - ['\\Temporal\\Api\\Workflowservice\\', '\\Temporal\\Client\\GRPC\\ContextInterface'], - ['', 'ContextInterface'], - $file->generate() - ) -); -echo "[OK]\n"; +$this->getInternalConnection()->setCapabilities($capabilities); +PHP); + return $method; +}; -echo "generating implementation: "; +$clients = [ + [ + 'label' => 'workflow', + 'serviceClass' => WorkflowServiceClient::class, + 'apiNamespacePrefix' => '\\Temporal\\Api\\Workflowservice\\V1\\', + 'interfaceName' => 'ServiceClientInterface', + 'implementationName' => 'ServiceClient', + 'interfaceFile' => __DIR__ . '/../../src/Client/GRPC/ServiceClientInterface.php', + 'implementationFile' => __DIR__ . '/../../src/Client/GRPC/ServiceClient.php', + 'extraUses' => [ + 'interface' => [ + 'Temporal\Client\Common\ServerCapabilities', + ], + 'implementation' => [ + 'Temporal\Api\Workflowservice\V1\GetSystemInfoRequest', + 'Temporal\Client\Common\ServerCapabilities', + ], + ], + 'extraInterfaceMethods' => static fn(): array => [$buildGetServerCapabilitiesInterfaceMethod()], + 'extraImplementationMethods' => static fn(): array => [ + $buildGetServerCapabilitiesImplementationMethod(), + $buildSetServerCapabilitiesMethod(), + $buildCreateServiceClientMethod(WorkflowServiceClient::class), + ], + ], + [ + 'label' => 'operator', + 'serviceClass' => OperatorServiceClient::class, + 'apiNamespacePrefix' => '\\Temporal\\Api\\Operatorservice\\V1\\', + 'interfaceName' => 'OperatorClientInterface', + 'implementationName' => 'OperatorClient', + 'interfaceFile' => __DIR__ . '/../../src/Client/GRPC/OperatorClientInterface.php', + 'implementationFile' => __DIR__ . '/../../src/Client/GRPC/OperatorClient.php', + 'extraUses' => [ + 'interface' => [], + 'implementation' => [], + ], + 'extraInterfaceMethods' => static fn(): array => [], + 'extraImplementationMethods' => static fn(): array => [ + $buildCreateServiceClientMethod(OperatorServiceClient::class), + ], + ], +]; + +$generatedFiles = []; + +foreach ($clients as $client) { + echo "reading {$client['label']} schema: "; + $serviceReflection = new ReflectionClass($client['serviceClass']); + $methods = $buildRpcMap($serviceReflection); + echo "[OK]\n"; + + // Collect all RPC request/response class FQCNs for use-imports + $rpcClasses = []; + foreach ($methods as $options) { + $rpcClasses[] = $options['request']; + $rpcClasses[] = $options['response']; + } + $rpcClasses = \array_unique($rpcClasses); + \sort($rpcClasses); + + // Common uses for all generated files + $commonUses = ['Temporal\Exception\Client\ServiceClientException']; -$impl = new Generator\ClassGenerator('ServiceClient'); -$impl->setExtendedClass('BaseClient'); + echo "generating {$client['interfaceName']}: "; + $interface = new Generator\InterfaceGenerator($client['interfaceName']); + $interface->setImplementedInterfaces([GrpcClientInterface::class]); -foreach ($methods as $method => $options) { - $m = new MethodGenerator($method); + foreach (($client['extraInterfaceMethods'])() as $method) { + $interface->addMethodFromGenerator($method); + } - $m->setDocBlock(($methodDocBlock)($r, $method, $options['request'], $options['response'])); - $m->setParameters( - [ + foreach ($methods as $name => $options) { + $method = new MethodGenerator($name); + $method->setDocBlock($buildMethodDocBlock($serviceReflection, $name, $options['request'], $options['response'])); + $method->setParameters([ Generator\ParameterGenerator::fromArray(['type' => $options['request'], 'name' => 'arg']), - $ctxParam - ] - ); - $m->setReturnType($options['response']); + $ctxParam, + ]); + $method->setReturnType($options['response']); + $interface->addMethodFromGenerator($method); + } - $m->setBody(sprintf('return $this->invoke("%s", $arg, $ctx);', $m->getName())); + echo "[OK]\n"; + + echo "writing {$client['interfaceName']}: "; + $file = new Generator\FileGenerator(); + $file->setNamespace('Temporal\\Client\\GRPC'); + $file->setDeclares([DeclareStatement::fromArray(['strict_types' => 1])]); + $file->setClass($interface); + $file->setUses([...$rpcClasses, ...$commonUses, ...($client['extraUses']['interface'] ?? [])]); + + \file_put_contents( + $client['interfaceFile'], + \str_replace( + [$client['apiNamespacePrefix'], '\\Temporal\\Client\\GRPC\\', '\\Temporal\\Client\\Common\\'], + ['', '', ''], + $file->generate(), + ), + ); + $generatedFiles[] = $client['interfaceFile']; + echo "[OK]\n"; + + echo "generating {$client['implementationName']}: "; + $implementation = new Generator\ClassGenerator($client['implementationName']); + $implementation->setExtendedClass('BaseClient'); + $implementation->setImplementedInterfaces([$client['interfaceName']]); + + foreach ($methods as $name => $options) { + $method = new MethodGenerator($name); + $method->setDocBlock($buildMethodDocBlock($serviceReflection, $name, $options['request'], $options['response'])); + $method->setParameters([ + Generator\ParameterGenerator::fromArray(['type' => $options['request'], 'name' => 'arg']), + $ctxParam, + ]); + $method->setReturnType($options['response']); + $method->setBody(\sprintf('return $this->invoke("%s", $arg, $ctx);', $name)); + $implementation->addMethodFromGenerator($method); + } - $impl->addMethodFromGenerator($m); + foreach (($client['extraImplementationMethods'])() as $method) { + $implementation->addMethodFromGenerator($method); + } + echo "[OK]\n"; + + echo "writing {$client['implementationName']}: "; + $file = new Generator\FileGenerator(); + $file->setNamespace('Temporal\\Client\\GRPC'); + $file->setDeclares([DeclareStatement::fromArray(['strict_types' => 1])]); + $file->setClass($implementation); + $file->setUses([...$rpcClasses, ...$commonUses, ...($client['extraUses']['implementation'] ?? []), $client['serviceClass']]); + + \file_put_contents( + $client['implementationFile'], + \str_replace( + [$client['apiNamespacePrefix'], '\\Temporal\\Client\\GRPC\\', '\\Temporal\\Client\\Common\\'], + ['', '', ''], + $file->generate(), + ), + ); + $generatedFiles[] = $client['implementationFile']; + echo "[OK]\n"; } -echo "[OK]\n"; - -echo "writing implementation: "; - -$file = new Generator\FileGenerator(); -$file->setNamespace('Temporal\\Client\\GRPC'); -$file->setClass($impl); -$file->setUses( - [ - 'Temporal\Api\Workflowservice\V1', - 'Temporal\Exception\Client\ServiceClientException', - ] -); - -// write and shorten names -file_put_contents( - __DIR__ . '/../../src/Client/GRPC/ServiceClient.php', - str_replace( - ['\\Temporal\\Api\\Workflowservice\\', '\\Temporal\\Client\\GRPC\\ContextInterface'], - ['', 'ContextInterface'], - $file->generate() - ) -); +echo "formatting generated files: "; +$command = \implode(' ', [ + \escapeshellarg(PHP_BINARY), + \escapeshellarg(__DIR__ . '/../../vendor/bin/php-cs-fixer'), + 'fix', + '--config=' . \escapeshellarg(__DIR__ . '/../../.php-cs-fixer.dist.php'), + '--path-mode=intersection', + '--using-cache=no', + '--allow-unsupported-php-version=yes', + '--sequential', + ...\array_map(static fn(string $path): string => \escapeshellarg($path), $generatedFiles), +]); + +\passthru($command, $exitCode); +$exitCode === 0 or throw new RuntimeException('Failed to format generated files.'); echo "[OK]\n"; diff --git a/src/Client/GRPC/BaseClient.php b/src/Client/GRPC/BaseClient.php index 1f80cbbea..a86160945 100644 --- a/src/Client/GRPC/BaseClient.php +++ b/src/Client/GRPC/BaseClient.php @@ -12,12 +12,10 @@ namespace Temporal\Client\GRPC; use Carbon\CarbonInterval; +use Grpc\BaseStub; use Grpc\UnaryCall; -use Temporal\Api\Workflowservice\V1\GetSystemInfoRequest; -use Temporal\Api\Workflowservice\V1\WorkflowServiceClient; use Temporal\Client\Common\BackoffThrottler; use Temporal\Client\Common\RpcRetryOptions; -use Temporal\Client\Common\ServerCapabilities; use Temporal\Client\GRPC\Connection\Connection; use Temporal\Client\GRPC\Connection\ConnectionInterface; use Temporal\Exception\Client\CanceledException; @@ -26,7 +24,7 @@ use Temporal\Interceptor\GrpcClientInterceptor; use Temporal\Internal\Interceptor\Pipeline; -abstract class BaseClient implements ServiceClientInterface +abstract class BaseClient implements GrpcClientInterface { public const RETRYABLE_ERRORS = [ StatusCode::RESOURCE_EXHAUSTED, @@ -42,23 +40,23 @@ abstract class BaseClient implements ServiceClientInterface private \Stringable|string $apiKey = ''; /** - * @param WorkflowServiceClient|\Closure(): WorkflowServiceClient $workflowService Service Client or its factory + * @param BaseStub|\Closure(): BaseStub $serviceClient Service Client or its factory * * @private Use static factory methods instead * @see self::create() * @see self::createSSL() */ - final public function __construct(WorkflowServiceClient|\Closure $workflowService) + final public function __construct(BaseStub|\Closure $serviceClient) { - if ($workflowService instanceof WorkflowServiceClient) { + if ($serviceClient instanceof BaseStub) { \trigger_error( - 'Creating a ServiceClient instance via constructor is deprecated. Use static factory methods instead.', + 'Creating a gRPC client instance via constructor is deprecated. Use static factory methods instead.', \E_USER_DEPRECATED, ); - $workflowService = static fn(): WorkflowServiceClient => $workflowService; + $serviceClient = static fn(): BaseStub => $serviceClient; } - $this->connection = new Connection($workflowService); + $this->connection = new Connection($serviceClient); $this->context = Context::default(); } @@ -72,10 +70,12 @@ public static function create(string $address): static throw new \RuntimeException('The gRPC extension is required to use Temporal Client.'); } - return new static(static fn(): WorkflowServiceClient => new WorkflowServiceClient( - $address, - ['credentials' => \Grpc\ChannelCredentials::createInsecure()], - )); + return new static( + static fn(): BaseStub => static::createGrpcStub( + $address, + ['credentials' => \Grpc\ChannelCredentials::createInsecure()], + ), + ); } /** @@ -123,7 +123,7 @@ public static function createSSL( $options['grpc.ssl_target_name_override'] = $overrideServerName; } - return new static(static fn(): WorkflowServiceClient => new WorkflowServiceClient($address, $options)); + return new static(static fn(): BaseStub => static::createGrpcStub($address, $options)); } public function getContext(): ContextInterface @@ -175,57 +175,18 @@ final public function withInterceptorPipeline(?Pipeline $pipeline): static return $clone; } - public function getServerCapabilities(): ?ServerCapabilities - { - if ($this->connection->capabilities !== null) { - return $this->connection->capabilities; - } - - try { - $systemInfo = $this->getSystemInfo(new GetSystemInfoRequest()); - $capabilities = $systemInfo->getCapabilities(); - - if ($capabilities === null) { - return null; - } - - return $this->connection->capabilities = new ServerCapabilities( - signalAndQueryHeader: $capabilities->getSignalAndQueryHeader(), - internalErrorDifferentiation: $capabilities->getInternalErrorDifferentiation(), - activityFailureIncludeHeartbeat: $capabilities->getActivityFailureIncludeHeartbeat(), - supportsSchedules: $capabilities->getSupportsSchedules(), - encodedFailureAttributes: $capabilities->getEncodedFailureAttributes(), - buildIdBasedVersioning: $capabilities->getBuildIdBasedVersioning(), - upsertMemo: $capabilities->getUpsertMemo(), - eagerWorkflowStart: $capabilities->getEagerWorkflowStart(), - sdkMetadata: $capabilities->getSdkMetadata(), - countGroupByExecutionStatus: $capabilities->getCountGroupByExecutionStatus(), - nexus: $capabilities->getNexus(), - ); - } catch (ServiceClientException $e) { - if ($e->getCode() === StatusCode::UNIMPLEMENTED) { - return null; - } - - throw $e; - } - } - /** - * @deprecated + * Note: Experimental */ - public function setServerCapabilities(ServerCapabilities $capabilities): void + public function getConnection(): ConnectionInterface { - \trigger_error( - 'Method ' . __METHOD__ . ' is deprecated and will be removed in the next major release.', - \E_USER_DEPRECATED, - ); + return $this->connection; } /** - * Note: Experimental + * @internal */ - public function getConnection(): ConnectionInterface + final protected function getInternalConnection(): Connection { return $this->connection; } @@ -252,6 +213,12 @@ protected function invoke(string $method, object $arg, ?ContextInterface $ctx = : $this->call($method, $arg, $ctx); } + /** + * @param non-empty-string $address Temporal service address in format `host:port` + * @param array $options + */ + abstract protected static function createGrpcStub(string $address, array $options): BaseStub; + /** * Call a gRPC method. * Used in {@see withInterceptorPipeline()} @@ -273,11 +240,11 @@ private function call(string $method, object $arg, ContextInterface $ctx): objec $deadline = $ctx->getDeadline(); if ($deadline !== null) { $diff = (new \DateTime())->diff($deadline); - $options['timeout'] = CarbonInterval::instance($diff)->totalMicroseconds; + $options['timeout'] = \max(0, (int) CarbonInterval::instance($diff)->totalMicroseconds); } /** @var UnaryCall $call */ - $call = $this->connection->getWorkflowService()->{$method}($arg, $ctx->getMetadata(), $options); + $call = $this->connection->getClient()->{$method}($arg, $ctx->getMetadata(), $options); [$result, $status] = $call->wait(); if ($status->code !== 0) { diff --git a/src/Client/GRPC/Connection/Connection.php b/src/Client/GRPC/Connection/Connection.php index de6db09f3..cc82367ed 100644 --- a/src/Client/GRPC/Connection/Connection.php +++ b/src/Client/GRPC/Connection/Connection.php @@ -4,7 +4,7 @@ namespace Temporal\Client\GRPC\Connection; -use Temporal\Api\Workflowservice\V1\WorkflowServiceClient; +use Grpc\BaseStub; use Temporal\Client\Common\ServerCapabilities; /** @@ -12,8 +12,8 @@ */ final class Connection implements ConnectionInterface { - public ?ServerCapabilities $capabilities = null; - private WorkflowServiceClient $workflowService; + private ?ServerCapabilities $capabilities = null; + private BaseStub $client; /** * True if ServiceClient wasn't created yet @@ -21,17 +21,17 @@ final class Connection implements ConnectionInterface private bool $closed = true; /** - * @param \Closure(): WorkflowServiceClient $clientFactory Service Client factory + * @param \Closure(): BaseStub $clientFactory Service Client factory */ public function __construct( - public \Closure $clientFactory, + private readonly \Closure $clientFactory, ) { $this->initClient(); } public function isConnected(): bool { - return ConnectionState::from($this->workflowService->getConnectivityState(false)) === ConnectionState::Ready; + return ConnectionState::from($this->client->getConnectivityState(false)) === ConnectionState::Ready; } public function connect(float $timeout): void @@ -56,7 +56,7 @@ public function connect(float $timeout): void if ($isFiber) { \Fiber::suspend(); } else { - $this->workflowService->waitForReady(50); + $this->client->waitForReady(50); } $alive = \microtime(true) < $deadline; @@ -83,16 +83,26 @@ public function disconnect(): void $this->closed = true; $this->capabilities = null; - $this->workflowService->close(); + $this->client->close(); + } + + public function getCapabilities(): ?ServerCapabilities + { + return $this->capabilities; + } + + public function setCapabilities(?ServerCapabilities $capabilities): void + { + $this->capabilities = $capabilities; } /** - * @return WorkflowServiceClient Shouldn't be cached + * @return BaseStub Shouldn't be cached */ - public function getWorkflowService(): WorkflowServiceClient + public function getClient(): BaseStub { $this->initClient(); - return $this->workflowService; + return $this->client; } public function __destruct() @@ -102,7 +112,7 @@ public function __destruct() private function getState(bool $tryToConnect = false): ConnectionState { - return ConnectionState::from($this->workflowService->getConnectivityState($tryToConnect)); + return ConnectionState::from($this->client->getConnectivityState($tryToConnect)); } /** @@ -114,7 +124,7 @@ private function initClient(): void return; } - $this->workflowService = ($this->clientFactory)(); + $this->client = ($this->clientFactory)(); $this->closed = false; } @@ -129,6 +139,6 @@ private function initClient(): void private function waitForReady(float $timeout): bool { /** @psalm-suppress InvalidOperand */ - return $this->workflowService->waitForReady((int) ($timeout * 1_000_000)); + return $this->client->waitForReady((int) ($timeout * 1_000_000)); } } diff --git a/src/Client/GRPC/GrpcClientInterface.php b/src/Client/GRPC/GrpcClientInterface.php new file mode 100644 index 000000000..2534c3471 --- /dev/null +++ b/src/Client/GRPC/GrpcClientInterface.php @@ -0,0 +1,23 @@ +invoke("AddSearchAttributes", $arg, $ctx); + } + + /** + * RemoveSearchAttributes removes custom search attributes. + * + * Returns NOT_FOUND status code if a Search Attribute with any of the specified + * names is not registered + * + * @throws ServiceClientException + */ + public function RemoveSearchAttributes(RemoveSearchAttributesRequest $arg, ?ContextInterface $ctx = null): RemoveSearchAttributesResponse + { + return $this->invoke("RemoveSearchAttributes", $arg, $ctx); + } + + /** + * ListSearchAttributes returns comprehensive information about search attributes. + * + * @throws ServiceClientException + */ + public function ListSearchAttributes(ListSearchAttributesRequest $arg, ?ContextInterface $ctx = null): ListSearchAttributesResponse + { + return $this->invoke("ListSearchAttributes", $arg, $ctx); + } + + /** + * DeleteNamespace synchronously deletes a namespace and asynchronously reclaims + * all namespace resources. + * + * @throws ServiceClientException + */ + public function DeleteNamespace(DeleteNamespaceRequest $arg, ?ContextInterface $ctx = null): DeleteNamespaceResponse + { + return $this->invoke("DeleteNamespace", $arg, $ctx); + } + + /** + * AddOrUpdateRemoteCluster adds or updates remote cluster. + * + * @throws ServiceClientException + */ + public function AddOrUpdateRemoteCluster(AddOrUpdateRemoteClusterRequest $arg, ?ContextInterface $ctx = null): AddOrUpdateRemoteClusterResponse + { + return $this->invoke("AddOrUpdateRemoteCluster", $arg, $ctx); + } + + /** + * RemoveRemoteCluster removes remote cluster. + * + * @throws ServiceClientException + */ + public function RemoveRemoteCluster(RemoveRemoteClusterRequest $arg, ?ContextInterface $ctx = null): RemoveRemoteClusterResponse + { + return $this->invoke("RemoveRemoteCluster", $arg, $ctx); + } + + /** + * ListClusters returns information about Temporal clusters. + * + * @throws ServiceClientException + */ + public function ListClusters(ListClustersRequest $arg, ?ContextInterface $ctx = null): ListClustersResponse + { + return $this->invoke("ListClusters", $arg, $ctx); + } + + /** + * Get a registered Nexus endpoint by ID. The returned version can be used for + * optimistic updates. + * + * @throws ServiceClientException + */ + public function GetNexusEndpoint(GetNexusEndpointRequest $arg, ?ContextInterface $ctx = null): GetNexusEndpointResponse + { + return $this->invoke("GetNexusEndpoint", $arg, $ctx); + } + + /** + * Create a Nexus endpoint. This will fail if an endpoint with the same name is + * already registered with a status of + * ALREADY_EXISTS. + * Returns the created endpoint with its initial version. You may use this version + * for subsequent updates. + * + * @throws ServiceClientException + */ + public function CreateNexusEndpoint(CreateNexusEndpointRequest $arg, ?ContextInterface $ctx = null): CreateNexusEndpointResponse + { + return $this->invoke("CreateNexusEndpoint", $arg, $ctx); + } + + /** + * Optimistically update a Nexus endpoint based on provided version as obtained via + * the `GetNexusEndpoint` or + * `ListNexusEndpointResponse` APIs. This will fail with a status of + * FAILED_PRECONDITION if the version does not + * match. + * Returns the updated endpoint with its updated version. You may use this version + * for subsequent updates. You don't + * need to increment the version yourself. The server will increment the version + * for you after each update. + * + * @throws ServiceClientException + */ + public function UpdateNexusEndpoint(UpdateNexusEndpointRequest $arg, ?ContextInterface $ctx = null): UpdateNexusEndpointResponse + { + return $this->invoke("UpdateNexusEndpoint", $arg, $ctx); + } + + /** + * Delete an incoming Nexus service by ID. + * + * @throws ServiceClientException + */ + public function DeleteNexusEndpoint(DeleteNexusEndpointRequest $arg, ?ContextInterface $ctx = null): DeleteNexusEndpointResponse + { + return $this->invoke("DeleteNexusEndpoint", $arg, $ctx); + } + + /** + * List all Nexus endpoints for the cluster, sorted by ID in ascending order. Set + * page_token in the request to the + * next_page_token field of the previous response to get the next page of results. + * An empty next_page_token + * indicates that there are no more results. During pagination, a newly added + * service with an ID lexicographically + * earlier than the previous page's last endpoint's ID may be missed. + * + * @throws ServiceClientException + */ + public function ListNexusEndpoints(ListNexusEndpointsRequest $arg, ?ContextInterface $ctx = null): ListNexusEndpointsResponse + { + return $this->invoke("ListNexusEndpoints", $arg, $ctx); + } + + protected static function createGrpcStub(string $address, array $options): \Grpc\BaseStub + { + return new OperatorServiceClient($address, $options); + } +} diff --git a/src/Client/GRPC/OperatorClientInterface.php b/src/Client/GRPC/OperatorClientInterface.php new file mode 100644 index 000000000..480073aa3 --- /dev/null +++ b/src/Client/GRPC/OperatorClientInterface.php @@ -0,0 +1,147 @@ +invoke("RegisterNamespace", $arg, $ctx); } @@ -34,7 +223,7 @@ public function RegisterNamespace(V1\RegisterNamespaceRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function DescribeNamespace(V1\DescribeNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\DescribeNamespaceResponse + public function DescribeNamespace(DescribeNamespaceRequest $arg, ?ContextInterface $ctx = null): DescribeNamespaceResponse { return $this->invoke("DescribeNamespace", $arg, $ctx); } @@ -44,7 +233,7 @@ public function DescribeNamespace(V1\DescribeNamespaceRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function ListNamespaces(V1\ListNamespacesRequest $arg, ?ContextInterface $ctx = null): V1\ListNamespacesResponse + public function ListNamespaces(ListNamespacesRequest $arg, ?ContextInterface $ctx = null): ListNamespacesResponse { return $this->invoke("ListNamespaces", $arg, $ctx); } @@ -56,7 +245,7 @@ public function ListNamespaces(V1\ListNamespacesRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\UpdateNamespaceResponse + public function UpdateNamespace(UpdateNamespaceRequest $arg, ?ContextInterface $ctx = null): UpdateNamespaceResponse { return $this->invoke("UpdateNamespace", $arg, $ctx); } @@ -75,7 +264,7 @@ public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ?ContextInterfac * * @throws ServiceClientException */ - public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\DeprecateNamespaceResponse + public function DeprecateNamespace(DeprecateNamespaceRequest $arg, ?ContextInterface $ctx = null): DeprecateNamespaceResponse { return $this->invoke("DeprecateNamespace", $arg, $ctx); } @@ -91,7 +280,7 @@ public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\StartWorkflowExecutionResponse + public function StartWorkflowExecution(StartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): StartWorkflowExecutionResponse { return $this->invoke("StartWorkflowExecution", $arg, $ctx); } @@ -107,11 +296,9 @@ public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ?C * Upon failure, it returns `MultiOperationExecutionFailure` where the status code * equals the status code of the *first* operation that failed to be started. * - * NOTE: Experimental API. - * * @throws ServiceClientException */ - public function ExecuteMultiOperation(V1\ExecuteMultiOperationRequest $arg, ?ContextInterface $ctx = null): V1\ExecuteMultiOperationResponse + public function ExecuteMultiOperation(ExecuteMultiOperationRequest $arg, ?ContextInterface $ctx = null): ExecuteMultiOperationResponse { return $this->invoke("ExecuteMultiOperation", $arg, $ctx); } @@ -123,7 +310,7 @@ public function ExecuteMultiOperation(V1\ExecuteMultiOperationRequest $arg, ?Con * * @throws ServiceClientException */ - public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryResponse + public function GetWorkflowExecutionHistory(GetWorkflowExecutionHistoryRequest $arg, ?ContextInterface $ctx = null): GetWorkflowExecutionHistoryResponse { return $this->invoke("GetWorkflowExecutionHistory", $arg, $ctx); } @@ -137,7 +324,7 @@ public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryReques * * @throws ServiceClientException */ - public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistoryReverseRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryReverseResponse + public function GetWorkflowExecutionHistoryReverse(GetWorkflowExecutionHistoryReverseRequest $arg, ?ContextInterface $ctx = null): GetWorkflowExecutionHistoryReverseResponse { return $this->invoke("GetWorkflowExecutionHistoryReverse", $arg, $ctx); } @@ -158,7 +345,7 @@ public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistor * * @throws ServiceClientException */ - public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollWorkflowTaskQueueResponse + public function PollWorkflowTaskQueue(PollWorkflowTaskQueueRequest $arg, ?ContextInterface $ctx = null): PollWorkflowTaskQueueResponse { return $this->invoke("PollWorkflowTaskQueue", $arg, $ctx); } @@ -179,7 +366,7 @@ public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, ?Con * * @throws ServiceClientException */ - public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondWorkflowTaskCompletedResponse + public function RespondWorkflowTaskCompleted(RespondWorkflowTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondWorkflowTaskCompletedResponse { return $this->invoke("RespondWorkflowTaskCompleted", $arg, $ctx); } @@ -204,7 +391,7 @@ public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequ * * @throws ServiceClientException */ - public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondWorkflowTaskFailedResponse + public function RespondWorkflowTaskFailed(RespondWorkflowTaskFailedRequest $arg, ?ContextInterface $ctx = null): RespondWorkflowTaskFailedResponse { return $this->invoke("RespondWorkflowTaskFailed", $arg, $ctx); } @@ -235,7 +422,7 @@ public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $a * * @throws ServiceClientException */ - public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollActivityTaskQueueResponse + public function PollActivityTaskQueue(PollActivityTaskQueueRequest $arg, ?ContextInterface $ctx = null): PollActivityTaskQueueResponse { return $this->invoke("PollActivityTaskQueue", $arg, $ctx); } @@ -255,7 +442,7 @@ public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, ?Con * * @throws ServiceClientException */ - public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatRequest $arg, ?ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatResponse + public function RecordActivityTaskHeartbeat(RecordActivityTaskHeartbeatRequest $arg, ?ContextInterface $ctx = null): RecordActivityTaskHeartbeatResponse { return $this->invoke("RecordActivityTaskHeartbeat", $arg, $ctx); } @@ -270,7 +457,7 @@ public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatReques * * @throws ServiceClientException */ - public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatByIdRequest $arg, ?ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatByIdResponse + public function RecordActivityTaskHeartbeatById(RecordActivityTaskHeartbeatByIdRequest $arg, ?ContextInterface $ctx = null): RecordActivityTaskHeartbeatByIdResponse { return $this->invoke("RecordActivityTaskHeartbeatById", $arg, $ctx); } @@ -289,7 +476,7 @@ public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatBy * * @throws ServiceClientException */ - public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCompletedResponse + public function RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCompletedResponse { return $this->invoke("RespondActivityTaskCompleted", $arg, $ctx); } @@ -304,7 +491,7 @@ public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequ * * @throws ServiceClientException */ - public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompletedByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCompletedByIdResponse + public function RespondActivityTaskCompletedById(RespondActivityTaskCompletedByIdRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCompletedByIdResponse { return $this->invoke("RespondActivityTaskCompletedById", $arg, $ctx); } @@ -322,7 +509,7 @@ public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompleted * * @throws ServiceClientException */ - public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskFailedResponse + public function RespondActivityTaskFailed(RespondActivityTaskFailedRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskFailedResponse { return $this->invoke("RespondActivityTaskFailed", $arg, $ctx); } @@ -337,7 +524,7 @@ public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $a * * @throws ServiceClientException */ - public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskFailedByIdResponse + public function RespondActivityTaskFailedById(RespondActivityTaskFailedByIdRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskFailedByIdResponse { return $this->invoke("RespondActivityTaskFailedById", $arg, $ctx); } @@ -355,7 +542,7 @@ public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRe * * @throws ServiceClientException */ - public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCanceledResponse + public function RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCanceledResponse { return $this->invoke("RespondActivityTaskCanceled", $arg, $ctx); } @@ -370,7 +557,7 @@ public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledReques * * @throws ServiceClientException */ - public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCanceledByIdResponse + public function RespondActivityTaskCanceledById(RespondActivityTaskCanceledByIdRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCanceledByIdResponse { return $this->invoke("RespondActivityTaskCanceledById", $arg, $ctx); } @@ -389,7 +576,7 @@ public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledBy * * @throws ServiceClientException */ - public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\RequestCancelWorkflowExecutionResponse + public function RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): RequestCancelWorkflowExecutionResponse { return $this->invoke("RequestCancelWorkflowExecution", $arg, $ctx); } @@ -404,7 +591,7 @@ public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecution * * @throws ServiceClientException */ - public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\SignalWorkflowExecutionResponse + public function SignalWorkflowExecution(SignalWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): SignalWorkflowExecutionResponse { return $this->invoke("SignalWorkflowExecution", $arg, $ctx); } @@ -428,7 +615,7 @@ public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, * * @throws ServiceClientException */ - public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\SignalWithStartWorkflowExecutionResponse + public function SignalWithStartWorkflowExecution(SignalWithStartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): SignalWithStartWorkflowExecutionResponse { return $this->invoke("SignalWithStartWorkflowExecution", $arg, $ctx); } @@ -443,7 +630,7 @@ public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecu * * @throws ServiceClientException */ - public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\ResetWorkflowExecutionResponse + public function ResetWorkflowExecution(ResetWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): ResetWorkflowExecutionResponse { return $this->invoke("ResetWorkflowExecution", $arg, $ctx); } @@ -457,7 +644,7 @@ public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, ?C * * @throws ServiceClientException */ - public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\TerminateWorkflowExecutionResponse + public function TerminateWorkflowExecution(TerminateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): TerminateWorkflowExecutionResponse { return $this->invoke("TerminateWorkflowExecution", $arg, $ctx); } @@ -476,7 +663,7 @@ public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest * * @throws ServiceClientException */ - public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkflowExecutionResponse + public function DeleteWorkflowExecution(DeleteWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): DeleteWorkflowExecutionResponse { return $this->invoke("DeleteWorkflowExecution", $arg, $ctx); } @@ -490,7 +677,7 @@ public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, * * @throws ServiceClientException */ - public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListOpenWorkflowExecutionsResponse + public function ListOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListOpenWorkflowExecutionsResponse { return $this->invoke("ListOpenWorkflowExecutions", $arg, $ctx); } @@ -504,7 +691,7 @@ public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest * * @throws ServiceClientException */ - public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListClosedWorkflowExecutionsResponse + public function ListClosedWorkflowExecutions(ListClosedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListClosedWorkflowExecutionsResponse { return $this->invoke("ListClosedWorkflowExecutions", $arg, $ctx); } @@ -515,7 +702,7 @@ public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequ * * @throws ServiceClientException */ - public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkflowExecutionsResponse + public function ListWorkflowExecutions(ListWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListWorkflowExecutionsResponse { return $this->invoke("ListWorkflowExecutions", $arg, $ctx); } @@ -526,14 +713,16 @@ public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, ?C * * @throws ServiceClientException */ - public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListArchivedWorkflowExecutionsResponse + public function ListArchivedWorkflowExecutions(ListArchivedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListArchivedWorkflowExecutionsResponse { return $this->invoke("ListArchivedWorkflowExecutions", $arg, $ctx); } /** - * ScanWorkflowExecutions is a visibility API to list large amount of workflow + * ScanWorkflowExecutions _was_ a visibility API to list large amount of workflow * executions in a specific namespace without order. + * It has since been deprecated in favor of `ListWorkflowExecutions` and rewritten + * to use `ListWorkflowExecutions` internally. * * Deprecated: Replaced with `ListWorkflowExecutions`. * (-- api-linter: core::0127::http-annotation=disabled @@ -541,7 +730,7 @@ public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutions * * @throws ServiceClientException */ - public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ScanWorkflowExecutionsResponse + public function ScanWorkflowExecutions(ScanWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ScanWorkflowExecutionsResponse { return $this->invoke("ScanWorkflowExecutions", $arg, $ctx); } @@ -552,7 +741,7 @@ public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, ?C * * @throws ServiceClientException */ - public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\CountWorkflowExecutionsResponse + public function CountWorkflowExecutions(CountWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): CountWorkflowExecutionsResponse { return $this->invoke("CountWorkflowExecutions", $arg, $ctx); } @@ -567,7 +756,7 @@ public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, * * @throws ServiceClientException */ - public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ?ContextInterface $ctx = null): V1\GetSearchAttributesResponse + public function GetSearchAttributes(GetSearchAttributesRequest $arg, ?ContextInterface $ctx = null): GetSearchAttributesResponse { return $this->invoke("GetSearchAttributes", $arg, $ctx); } @@ -586,7 +775,7 @@ public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ?Context * * @throws ServiceClientException */ - public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondQueryTaskCompletedResponse + public function RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondQueryTaskCompletedResponse { return $this->invoke("RespondQueryTaskCompleted", $arg, $ctx); } @@ -611,7 +800,7 @@ public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $a * * @throws ServiceClientException */ - public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\ResetStickyTaskQueueResponse + public function ResetStickyTaskQueue(ResetStickyTaskQueueRequest $arg, ?ContextInterface $ctx = null): ResetStickyTaskQueueResponse { return $this->invoke("ResetStickyTaskQueue", $arg, $ctx); } @@ -633,7 +822,7 @@ public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, ?Conte * * @throws ServiceClientException */ - public function ShutdownWorker(V1\ShutdownWorkerRequest $arg, ?ContextInterface $ctx = null): V1\ShutdownWorkerResponse + public function ShutdownWorker(ShutdownWorkerRequest $arg, ?ContextInterface $ctx = null): ShutdownWorkerResponse { return $this->invoke("ShutdownWorker", $arg, $ctx); } @@ -643,7 +832,7 @@ public function ShutdownWorker(V1\ShutdownWorkerRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ?ContextInterface $ctx = null): V1\QueryWorkflowResponse + public function QueryWorkflow(QueryWorkflowRequest $arg, ?ContextInterface $ctx = null): QueryWorkflowResponse { return $this->invoke("QueryWorkflow", $arg, $ctx); } @@ -654,7 +843,7 @@ public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkflowExecutionResponse + public function DescribeWorkflowExecution(DescribeWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): DescribeWorkflowExecutionResponse { return $this->invoke("DescribeWorkflowExecution", $arg, $ctx); } @@ -668,7 +857,7 @@ public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $a * * @throws ServiceClientException */ - public function DescribeTaskQueue(V1\DescribeTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\DescribeTaskQueueResponse + public function DescribeTaskQueue(DescribeTaskQueueRequest $arg, ?ContextInterface $ctx = null): DescribeTaskQueueResponse { return $this->invoke("DescribeTaskQueue", $arg, $ctx); } @@ -678,7 +867,7 @@ public function DescribeTaskQueue(V1\DescribeTaskQueueRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function GetClusterInfo(V1\GetClusterInfoRequest $arg, ?ContextInterface $ctx = null): V1\GetClusterInfoResponse + public function GetClusterInfo(GetClusterInfoRequest $arg, ?ContextInterface $ctx = null): GetClusterInfoResponse { return $this->invoke("GetClusterInfo", $arg, $ctx); } @@ -688,7 +877,7 @@ public function GetClusterInfo(V1\GetClusterInfoRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ?ContextInterface $ctx = null): V1\GetSystemInfoResponse + public function GetSystemInfo(GetSystemInfoRequest $arg, ?ContextInterface $ctx = null): GetSystemInfoResponse { return $this->invoke("GetSystemInfo", $arg, $ctx); } @@ -699,7 +888,7 @@ public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function ListTaskQueuePartitions(V1\ListTaskQueuePartitionsRequest $arg, ?ContextInterface $ctx = null): V1\ListTaskQueuePartitionsResponse + public function ListTaskQueuePartitions(ListTaskQueuePartitionsRequest $arg, ?ContextInterface $ctx = null): ListTaskQueuePartitionsResponse { return $this->invoke("ListTaskQueuePartitions", $arg, $ctx); } @@ -709,7 +898,7 @@ public function ListTaskQueuePartitions(V1\ListTaskQueuePartitionsRequest $arg, * * @throws ServiceClientException */ - public function CreateSchedule(V1\CreateScheduleRequest $arg, ?ContextInterface $ctx = null): V1\CreateScheduleResponse + public function CreateSchedule(CreateScheduleRequest $arg, ?ContextInterface $ctx = null): CreateScheduleResponse { return $this->invoke("CreateSchedule", $arg, $ctx); } @@ -719,7 +908,7 @@ public function CreateSchedule(V1\CreateScheduleRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function DescribeSchedule(V1\DescribeScheduleRequest $arg, ?ContextInterface $ctx = null): V1\DescribeScheduleResponse + public function DescribeSchedule(DescribeScheduleRequest $arg, ?ContextInterface $ctx = null): DescribeScheduleResponse { return $this->invoke("DescribeSchedule", $arg, $ctx); } @@ -729,7 +918,7 @@ public function DescribeSchedule(V1\DescribeScheduleRequest $arg, ?ContextInterf * * @throws ServiceClientException */ - public function UpdateSchedule(V1\UpdateScheduleRequest $arg, ?ContextInterface $ctx = null): V1\UpdateScheduleResponse + public function UpdateSchedule(UpdateScheduleRequest $arg, ?ContextInterface $ctx = null): UpdateScheduleResponse { return $this->invoke("UpdateSchedule", $arg, $ctx); } @@ -739,7 +928,7 @@ public function UpdateSchedule(V1\UpdateScheduleRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function PatchSchedule(V1\PatchScheduleRequest $arg, ?ContextInterface $ctx = null): V1\PatchScheduleResponse + public function PatchSchedule(PatchScheduleRequest $arg, ?ContextInterface $ctx = null): PatchScheduleResponse { return $this->invoke("PatchSchedule", $arg, $ctx); } @@ -749,7 +938,7 @@ public function PatchSchedule(V1\PatchScheduleRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function ListScheduleMatchingTimes(V1\ListScheduleMatchingTimesRequest $arg, ?ContextInterface $ctx = null): V1\ListScheduleMatchingTimesResponse + public function ListScheduleMatchingTimes(ListScheduleMatchingTimesRequest $arg, ?ContextInterface $ctx = null): ListScheduleMatchingTimesResponse { return $this->invoke("ListScheduleMatchingTimes", $arg, $ctx); } @@ -759,7 +948,7 @@ public function ListScheduleMatchingTimes(V1\ListScheduleMatchingTimesRequest $a * * @throws ServiceClientException */ - public function DeleteSchedule(V1\DeleteScheduleRequest $arg, ?ContextInterface $ctx = null): V1\DeleteScheduleResponse + public function DeleteSchedule(DeleteScheduleRequest $arg, ?ContextInterface $ctx = null): DeleteScheduleResponse { return $this->invoke("DeleteSchedule", $arg, $ctx); } @@ -769,7 +958,7 @@ public function DeleteSchedule(V1\DeleteScheduleRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function ListSchedules(V1\ListSchedulesRequest $arg, ?ContextInterface $ctx = null): V1\ListSchedulesResponse + public function ListSchedules(ListSchedulesRequest $arg, ?ContextInterface $ctx = null): ListSchedulesResponse { return $this->invoke("ListSchedules", $arg, $ctx); } @@ -801,7 +990,7 @@ public function ListSchedules(V1\ListSchedulesRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerBuildIdCompatibilityResponse + public function UpdateWorkerBuildIdCompatibility(UpdateWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerBuildIdCompatibilityResponse { return $this->invoke("UpdateWorkerBuildIdCompatibility", $arg, $ctx); } @@ -812,7 +1001,7 @@ public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibi * * @throws ServiceClientException */ - public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerBuildIdCompatibilityResponse + public function GetWorkerBuildIdCompatibility(GetWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): GetWorkerBuildIdCompatibilityResponse { return $this->invoke("GetWorkerBuildIdCompatibility", $arg, $ctx); } @@ -859,7 +1048,7 @@ public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRe * * @throws ServiceClientException */ - public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerVersioningRulesResponse + public function UpdateWorkerVersioningRules(UpdateWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerVersioningRulesResponse { return $this->invoke("UpdateWorkerVersioningRules", $arg, $ctx); } @@ -871,7 +1060,7 @@ public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesReques * * @throws ServiceClientException */ - public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerVersioningRulesResponse + public function GetWorkerVersioningRules(GetWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): GetWorkerVersioningRulesResponse { return $this->invoke("GetWorkerVersioningRules", $arg, $ctx); } @@ -901,7 +1090,7 @@ public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg * * @throws ServiceClientException */ - public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerTaskReachabilityResponse + public function GetWorkerTaskReachability(GetWorkerTaskReachabilityRequest $arg, ?ContextInterface $ctx = null): GetWorkerTaskReachabilityResponse { return $this->invoke("GetWorkerTaskReachability", $arg, $ctx); } @@ -912,7 +1101,7 @@ public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $a * * @throws ServiceClientException */ - public function DescribeDeployment(V1\DescribeDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\DescribeDeploymentResponse + public function DescribeDeployment(DescribeDeploymentRequest $arg, ?ContextInterface $ctx = null): DescribeDeploymentResponse { return $this->invoke("DescribeDeployment", $arg, $ctx); } @@ -922,7 +1111,7 @@ public function DescribeDeployment(V1\DescribeDeploymentRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function DescribeWorkerDeploymentVersion(V1\DescribeWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkerDeploymentVersionResponse + public function DescribeWorkerDeploymentVersion(DescribeWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): DescribeWorkerDeploymentVersionResponse { return $this->invoke("DescribeWorkerDeploymentVersion", $arg, $ctx); } @@ -935,7 +1124,7 @@ public function DescribeWorkerDeploymentVersion(V1\DescribeWorkerDeploymentVersi * * @throws ServiceClientException */ - public function ListDeployments(V1\ListDeploymentsRequest $arg, ?ContextInterface $ctx = null): V1\ListDeploymentsResponse + public function ListDeployments(ListDeploymentsRequest $arg, ?ContextInterface $ctx = null): ListDeploymentsResponse { return $this->invoke("ListDeployments", $arg, $ctx); } @@ -957,7 +1146,7 @@ public function ListDeployments(V1\ListDeploymentsRequest $arg, ?ContextInterfac * * @throws ServiceClientException */ - public function GetDeploymentReachability(V1\GetDeploymentReachabilityRequest $arg, ?ContextInterface $ctx = null): V1\GetDeploymentReachabilityResponse + public function GetDeploymentReachability(GetDeploymentReachabilityRequest $arg, ?ContextInterface $ctx = null): GetDeploymentReachabilityResponse { return $this->invoke("GetDeploymentReachability", $arg, $ctx); } @@ -969,7 +1158,7 @@ public function GetDeploymentReachability(V1\GetDeploymentReachabilityRequest $a * * @throws ServiceClientException */ - public function GetCurrentDeployment(V1\GetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\GetCurrentDeploymentResponse + public function GetCurrentDeployment(GetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): GetCurrentDeploymentResponse { return $this->invoke("GetCurrentDeployment", $arg, $ctx); } @@ -982,7 +1171,7 @@ public function GetCurrentDeployment(V1\GetCurrentDeploymentRequest $arg, ?Conte * * @throws ServiceClientException */ - public function SetCurrentDeployment(V1\SetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\SetCurrentDeploymentResponse + public function SetCurrentDeployment(SetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): SetCurrentDeploymentResponse { return $this->invoke("SetCurrentDeployment", $arg, $ctx); } @@ -994,7 +1183,7 @@ public function SetCurrentDeployment(V1\SetCurrentDeploymentRequest $arg, ?Conte * * @throws ServiceClientException */ - public function SetWorkerDeploymentCurrentVersion(V1\SetWorkerDeploymentCurrentVersionRequest $arg, ?ContextInterface $ctx = null): V1\SetWorkerDeploymentCurrentVersionResponse + public function SetWorkerDeploymentCurrentVersion(SetWorkerDeploymentCurrentVersionRequest $arg, ?ContextInterface $ctx = null): SetWorkerDeploymentCurrentVersionResponse { return $this->invoke("SetWorkerDeploymentCurrentVersion", $arg, $ctx); } @@ -1004,7 +1193,7 @@ public function SetWorkerDeploymentCurrentVersion(V1\SetWorkerDeploymentCurrentV * * @throws ServiceClientException */ - public function DescribeWorkerDeployment(V1\DescribeWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkerDeploymentResponse + public function DescribeWorkerDeployment(DescribeWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): DescribeWorkerDeploymentResponse { return $this->invoke("DescribeWorkerDeployment", $arg, $ctx); } @@ -1015,7 +1204,7 @@ public function DescribeWorkerDeployment(V1\DescribeWorkerDeploymentRequest $arg * * @throws ServiceClientException */ - public function DeleteWorkerDeployment(V1\DeleteWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkerDeploymentResponse + public function DeleteWorkerDeployment(DeleteWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): DeleteWorkerDeploymentResponse { return $this->invoke("DeleteWorkerDeployment", $arg, $ctx); } @@ -1032,7 +1221,7 @@ public function DeleteWorkerDeployment(V1\DeleteWorkerDeploymentRequest $arg, ?C * * @throws ServiceClientException */ - public function DeleteWorkerDeploymentVersion(V1\DeleteWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkerDeploymentVersionResponse + public function DeleteWorkerDeploymentVersion(DeleteWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): DeleteWorkerDeploymentVersionResponse { return $this->invoke("DeleteWorkerDeploymentVersion", $arg, $ctx); } @@ -1044,7 +1233,7 @@ public function DeleteWorkerDeploymentVersion(V1\DeleteWorkerDeploymentVersionRe * * @throws ServiceClientException */ - public function SetWorkerDeploymentRampingVersion(V1\SetWorkerDeploymentRampingVersionRequest $arg, ?ContextInterface $ctx = null): V1\SetWorkerDeploymentRampingVersionResponse + public function SetWorkerDeploymentRampingVersion(SetWorkerDeploymentRampingVersionRequest $arg, ?ContextInterface $ctx = null): SetWorkerDeploymentRampingVersionResponse { return $this->invoke("SetWorkerDeploymentRampingVersion", $arg, $ctx); } @@ -1054,7 +1243,7 @@ public function SetWorkerDeploymentRampingVersion(V1\SetWorkerDeploymentRampingV * * @throws ServiceClientException */ - public function ListWorkerDeployments(V1\ListWorkerDeploymentsRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkerDeploymentsResponse + public function ListWorkerDeployments(ListWorkerDeploymentsRequest $arg, ?ContextInterface $ctx = null): ListWorkerDeploymentsResponse { return $this->invoke("ListWorkerDeployments", $arg, $ctx); } @@ -1064,17 +1253,27 @@ public function ListWorkerDeployments(V1\ListWorkerDeploymentsRequest $arg, ?Con * * @throws ServiceClientException */ - public function UpdateWorkerDeploymentVersionMetadata(V1\UpdateWorkerDeploymentVersionMetadataRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerDeploymentVersionMetadataResponse + public function UpdateWorkerDeploymentVersionMetadata(UpdateWorkerDeploymentVersionMetadataRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerDeploymentVersionMetadataResponse { return $this->invoke("UpdateWorkerDeploymentVersionMetadata", $arg, $ctx); } + /** + * Set/unset the ManagerIdentity of a Worker Deployment. + * + * @throws ServiceClientException + */ + public function SetWorkerDeploymentManager(SetWorkerDeploymentManagerRequest $arg, ?ContextInterface $ctx = null): SetWorkerDeploymentManagerResponse + { + return $this->invoke("SetWorkerDeploymentManager", $arg, $ctx); + } + /** * Invokes the specified Update function on user Workflow code. * * @throws ServiceClientException */ - public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkflowExecutionResponse + public function UpdateWorkflowExecution(UpdateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): UpdateWorkflowExecutionResponse { return $this->invoke("UpdateWorkflowExecution", $arg, $ctx); } @@ -1091,7 +1290,7 @@ public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, * * @throws ServiceClientException */ - public function PollWorkflowExecutionUpdate(V1\PollWorkflowExecutionUpdateRequest $arg, ?ContextInterface $ctx = null): V1\PollWorkflowExecutionUpdateResponse + public function PollWorkflowExecutionUpdate(PollWorkflowExecutionUpdateRequest $arg, ?ContextInterface $ctx = null): PollWorkflowExecutionUpdateResponse { return $this->invoke("PollWorkflowExecutionUpdate", $arg, $ctx); } @@ -1101,7 +1300,7 @@ public function PollWorkflowExecutionUpdate(V1\PollWorkflowExecutionUpdateReques * * @throws ServiceClientException */ - public function StartBatchOperation(V1\StartBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\StartBatchOperationResponse + public function StartBatchOperation(StartBatchOperationRequest $arg, ?ContextInterface $ctx = null): StartBatchOperationResponse { return $this->invoke("StartBatchOperation", $arg, $ctx); } @@ -1111,7 +1310,7 @@ public function StartBatchOperation(V1\StartBatchOperationRequest $arg, ?Context * * @throws ServiceClientException */ - public function StopBatchOperation(V1\StopBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\StopBatchOperationResponse + public function StopBatchOperation(StopBatchOperationRequest $arg, ?ContextInterface $ctx = null): StopBatchOperationResponse { return $this->invoke("StopBatchOperation", $arg, $ctx); } @@ -1121,7 +1320,7 @@ public function StopBatchOperation(V1\StopBatchOperationRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function DescribeBatchOperation(V1\DescribeBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\DescribeBatchOperationResponse + public function DescribeBatchOperation(DescribeBatchOperationRequest $arg, ?ContextInterface $ctx = null): DescribeBatchOperationResponse { return $this->invoke("DescribeBatchOperation", $arg, $ctx); } @@ -1131,7 +1330,7 @@ public function DescribeBatchOperation(V1\DescribeBatchOperationRequest $arg, ?C * * @throws ServiceClientException */ - public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ?ContextInterface $ctx = null): V1\ListBatchOperationsResponse + public function ListBatchOperations(ListBatchOperationsRequest $arg, ?ContextInterface $ctx = null): ListBatchOperationsResponse { return $this->invoke("ListBatchOperations", $arg, $ctx); } @@ -1143,7 +1342,7 @@ public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ?Context * * @throws ServiceClientException */ - public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollNexusTaskQueueResponse + public function PollNexusTaskQueue(PollNexusTaskQueueRequest $arg, ?ContextInterface $ctx = null): PollNexusTaskQueueResponse { return $this->invoke("PollNexusTaskQueue", $arg, $ctx); } @@ -1156,7 +1355,7 @@ public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondNexusTaskCompletedResponse + public function RespondNexusTaskCompleted(RespondNexusTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondNexusTaskCompletedResponse { return $this->invoke("RespondNexusTaskCompleted", $arg, $ctx); } @@ -1169,7 +1368,7 @@ public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $a * * @throws ServiceClientException */ - public function RespondNexusTaskFailed(V1\RespondNexusTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondNexusTaskFailedResponse + public function RespondNexusTaskFailed(RespondNexusTaskFailedRequest $arg, ?ContextInterface $ctx = null): RespondNexusTaskFailedResponse { return $this->invoke("RespondNexusTaskFailed", $arg, $ctx); } @@ -1182,7 +1381,7 @@ public function RespondNexusTaskFailed(V1\RespondNexusTaskFailedRequest $arg, ?C * * @throws ServiceClientException */ - public function UpdateActivityOptions(V1\UpdateActivityOptionsRequest $arg, ?ContextInterface $ctx = null): V1\UpdateActivityOptionsResponse + public function UpdateActivityOptions(UpdateActivityOptionsRequest $arg, ?ContextInterface $ctx = null): UpdateActivityOptionsResponse { return $this->invoke("UpdateActivityOptions", $arg, $ctx); } @@ -1193,7 +1392,7 @@ public function UpdateActivityOptions(V1\UpdateActivityOptionsRequest $arg, ?Con * * @throws ServiceClientException */ - public function UpdateWorkflowExecutionOptions(V1\UpdateWorkflowExecutionOptionsRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkflowExecutionOptionsResponse + public function UpdateWorkflowExecutionOptions(UpdateWorkflowExecutionOptionsRequest $arg, ?ContextInterface $ctx = null): UpdateWorkflowExecutionOptionsResponse { return $this->invoke("UpdateWorkflowExecutionOptions", $arg, $ctx); } @@ -1223,7 +1422,7 @@ public function UpdateWorkflowExecutionOptions(V1\UpdateWorkflowExecutionOptions * * @throws ServiceClientException */ - public function PauseActivity(V1\PauseActivityRequest $arg, ?ContextInterface $ctx = null): V1\PauseActivityResponse + public function PauseActivity(PauseActivityRequest $arg, ?ContextInterface $ctx = null): PauseActivityResponse { return $this->invoke("PauseActivity", $arg, $ctx); } @@ -1250,7 +1449,7 @@ public function PauseActivity(V1\PauseActivityRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function UnpauseActivity(V1\UnpauseActivityRequest $arg, ?ContextInterface $ctx = null): V1\UnpauseActivityResponse + public function UnpauseActivity(UnpauseActivityRequest $arg, ?ContextInterface $ctx = null): UnpauseActivityResponse { return $this->invoke("UnpauseActivity", $arg, $ctx); } @@ -1281,7 +1480,7 @@ public function UnpauseActivity(V1\UnpauseActivityRequest $arg, ?ContextInterfac * * @throws ServiceClientException */ - public function ResetActivity(V1\ResetActivityRequest $arg, ?ContextInterface $ctx = null): V1\ResetActivityResponse + public function ResetActivity(ResetActivityRequest $arg, ?ContextInterface $ctx = null): ResetActivityResponse { return $this->invoke("ResetActivity", $arg, $ctx); } @@ -1297,7 +1496,7 @@ public function ResetActivity(V1\ResetActivityRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function CreateWorkflowRule(V1\CreateWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\CreateWorkflowRuleResponse + public function CreateWorkflowRule(CreateWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): CreateWorkflowRuleResponse { return $this->invoke("CreateWorkflowRule", $arg, $ctx); } @@ -1308,7 +1507,7 @@ public function CreateWorkflowRule(V1\CreateWorkflowRuleRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function DescribeWorkflowRule(V1\DescribeWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkflowRuleResponse + public function DescribeWorkflowRule(DescribeWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): DescribeWorkflowRuleResponse { return $this->invoke("DescribeWorkflowRule", $arg, $ctx); } @@ -1318,7 +1517,7 @@ public function DescribeWorkflowRule(V1\DescribeWorkflowRuleRequest $arg, ?Conte * * @throws ServiceClientException */ - public function DeleteWorkflowRule(V1\DeleteWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkflowRuleResponse + public function DeleteWorkflowRule(DeleteWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): DeleteWorkflowRuleResponse { return $this->invoke("DeleteWorkflowRule", $arg, $ctx); } @@ -1328,7 +1527,7 @@ public function DeleteWorkflowRule(V1\DeleteWorkflowRuleRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function ListWorkflowRules(V1\ListWorkflowRulesRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkflowRulesResponse + public function ListWorkflowRules(ListWorkflowRulesRequest $arg, ?ContextInterface $ctx = null): ListWorkflowRulesResponse { return $this->invoke("ListWorkflowRules", $arg, $ctx); } @@ -1341,7 +1540,7 @@ public function ListWorkflowRules(V1\ListWorkflowRulesRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function TriggerWorkflowRule(V1\TriggerWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\TriggerWorkflowRuleResponse + public function TriggerWorkflowRule(TriggerWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): TriggerWorkflowRuleResponse { return $this->invoke("TriggerWorkflowRule", $arg, $ctx); } @@ -1351,7 +1550,7 @@ public function TriggerWorkflowRule(V1\TriggerWorkflowRuleRequest $arg, ?Context * * @throws ServiceClientException */ - public function RecordWorkerHeartbeat(V1\RecordWorkerHeartbeatRequest $arg, ?ContextInterface $ctx = null): V1\RecordWorkerHeartbeatResponse + public function RecordWorkerHeartbeat(RecordWorkerHeartbeatRequest $arg, ?ContextInterface $ctx = null): RecordWorkerHeartbeatResponse { return $this->invoke("RecordWorkerHeartbeat", $arg, $ctx); } @@ -1362,7 +1561,7 @@ public function RecordWorkerHeartbeat(V1\RecordWorkerHeartbeatRequest $arg, ?Con * * @throws ServiceClientException */ - public function ListWorkers(V1\ListWorkersRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkersResponse + public function ListWorkers(ListWorkersRequest $arg, ?ContextInterface $ctx = null): ListWorkersResponse { return $this->invoke("ListWorkers", $arg, $ctx); } @@ -1377,7 +1576,7 @@ public function ListWorkers(V1\ListWorkersRequest $arg, ?ContextInterface $ctx = * * @throws ServiceClientException */ - public function UpdateTaskQueueConfig(V1\UpdateTaskQueueConfigRequest $arg, ?ContextInterface $ctx = null): V1\UpdateTaskQueueConfigResponse + public function UpdateTaskQueueConfig(UpdateTaskQueueConfigRequest $arg, ?ContextInterface $ctx = null): UpdateTaskQueueConfigResponse { return $this->invoke("UpdateTaskQueueConfig", $arg, $ctx); } @@ -1387,7 +1586,7 @@ public function UpdateTaskQueueConfig(V1\UpdateTaskQueueConfigRequest $arg, ?Con * * @throws ServiceClientException */ - public function FetchWorkerConfig(V1\FetchWorkerConfigRequest $arg, ?ContextInterface $ctx = null): V1\FetchWorkerConfigResponse + public function FetchWorkerConfig(FetchWorkerConfigRequest $arg, ?ContextInterface $ctx = null): FetchWorkerConfigResponse { return $this->invoke("FetchWorkerConfig", $arg, $ctx); } @@ -1399,8 +1598,73 @@ public function FetchWorkerConfig(V1\FetchWorkerConfigRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function UpdateWorkerConfig(V1\UpdateWorkerConfigRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerConfigResponse + public function UpdateWorkerConfig(UpdateWorkerConfigRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerConfigResponse { return $this->invoke("UpdateWorkerConfig", $arg, $ctx); } + + /** + * DescribeWorker returns information about the specified worker. + * + * @throws ServiceClientException + */ + public function DescribeWorker(DescribeWorkerRequest $arg, ?ContextInterface $ctx = null): DescribeWorkerResponse + { + return $this->invoke("DescribeWorker", $arg, $ctx); + } + + public function getServerCapabilities(): ?ServerCapabilities + { + $connection = $this->getInternalConnection(); + if ($connection->getCapabilities() !== null) { + return $connection->getCapabilities(); + } + + try { + $systemInfo = $this->getSystemInfo(new GetSystemInfoRequest()); + $capabilities = $systemInfo->getCapabilities(); + + if ($capabilities === null) { + return null; + } + + $serverCapabilities = new ServerCapabilities( + signalAndQueryHeader: $capabilities->getSignalAndQueryHeader(), + internalErrorDifferentiation: $capabilities->getInternalErrorDifferentiation(), + activityFailureIncludeHeartbeat: $capabilities->getActivityFailureIncludeHeartbeat(), + supportsSchedules: $capabilities->getSupportsSchedules(), + encodedFailureAttributes: $capabilities->getEncodedFailureAttributes(), + buildIdBasedVersioning: $capabilities->getBuildIdBasedVersioning(), + upsertMemo: $capabilities->getUpsertMemo(), + eagerWorkflowStart: $capabilities->getEagerWorkflowStart(), + sdkMetadata: $capabilities->getSdkMetadata(), + countGroupByExecutionStatus: $capabilities->getCountGroupByExecutionStatus(), + nexus: $capabilities->getNexus(), + ); + $connection->setCapabilities($serverCapabilities); + + return $serverCapabilities; + } catch (ServiceClientException $e) { + if ($e->getCode() === StatusCode::UNIMPLEMENTED) { + return null; + } + + throw $e; + } + } + + public function setServerCapabilities(ServerCapabilities $capabilities): void + { + \trigger_error( + 'Method ' . __METHOD__ . ' is deprecated and will be removed in the next major release.', + \E_USER_DEPRECATED, + ); + + $this->getInternalConnection()->setCapabilities($capabilities); + } + + protected static function createGrpcStub(string $address, array $options): \Grpc\BaseStub + { + return new WorkflowServiceClient($address, $options); + } } diff --git a/src/Client/GRPC/ServiceClientInterface.php b/src/Client/GRPC/ServiceClientInterface.php index 1f262bfa0..5bc250973 100644 --- a/src/Client/GRPC/ServiceClientInterface.php +++ b/src/Client/GRPC/ServiceClientInterface.php @@ -4,20 +4,200 @@ namespace Temporal\Client\GRPC; -use Temporal\Api\Workflowservice\V1; +use Temporal\Api\Workflowservice\V1\CountWorkflowExecutionsRequest; +use Temporal\Api\Workflowservice\V1\CountWorkflowExecutionsResponse; +use Temporal\Api\Workflowservice\V1\CreateScheduleRequest; +use Temporal\Api\Workflowservice\V1\CreateScheduleResponse; +use Temporal\Api\Workflowservice\V1\CreateWorkflowRuleRequest; +use Temporal\Api\Workflowservice\V1\CreateWorkflowRuleResponse; +use Temporal\Api\Workflowservice\V1\DeleteScheduleRequest; +use Temporal\Api\Workflowservice\V1\DeleteScheduleResponse; +use Temporal\Api\Workflowservice\V1\DeleteWorkerDeploymentRequest; +use Temporal\Api\Workflowservice\V1\DeleteWorkerDeploymentResponse; +use Temporal\Api\Workflowservice\V1\DeleteWorkerDeploymentVersionRequest; +use Temporal\Api\Workflowservice\V1\DeleteWorkerDeploymentVersionResponse; +use Temporal\Api\Workflowservice\V1\DeleteWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\DeleteWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\DeleteWorkflowRuleRequest; +use Temporal\Api\Workflowservice\V1\DeleteWorkflowRuleResponse; +use Temporal\Api\Workflowservice\V1\DeprecateNamespaceRequest; +use Temporal\Api\Workflowservice\V1\DeprecateNamespaceResponse; +use Temporal\Api\Workflowservice\V1\DescribeBatchOperationRequest; +use Temporal\Api\Workflowservice\V1\DescribeBatchOperationResponse; +use Temporal\Api\Workflowservice\V1\DescribeDeploymentRequest; +use Temporal\Api\Workflowservice\V1\DescribeDeploymentResponse; +use Temporal\Api\Workflowservice\V1\DescribeNamespaceRequest; +use Temporal\Api\Workflowservice\V1\DescribeNamespaceResponse; +use Temporal\Api\Workflowservice\V1\DescribeScheduleRequest; +use Temporal\Api\Workflowservice\V1\DescribeScheduleResponse; +use Temporal\Api\Workflowservice\V1\DescribeTaskQueueRequest; +use Temporal\Api\Workflowservice\V1\DescribeTaskQueueResponse; +use Temporal\Api\Workflowservice\V1\DescribeWorkerDeploymentRequest; +use Temporal\Api\Workflowservice\V1\DescribeWorkerDeploymentResponse; +use Temporal\Api\Workflowservice\V1\DescribeWorkerDeploymentVersionRequest; +use Temporal\Api\Workflowservice\V1\DescribeWorkerDeploymentVersionResponse; +use Temporal\Api\Workflowservice\V1\DescribeWorkerRequest; +use Temporal\Api\Workflowservice\V1\DescribeWorkerResponse; +use Temporal\Api\Workflowservice\V1\DescribeWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\DescribeWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\DescribeWorkflowRuleRequest; +use Temporal\Api\Workflowservice\V1\DescribeWorkflowRuleResponse; +use Temporal\Api\Workflowservice\V1\ExecuteMultiOperationRequest; +use Temporal\Api\Workflowservice\V1\ExecuteMultiOperationResponse; +use Temporal\Api\Workflowservice\V1\FetchWorkerConfigRequest; +use Temporal\Api\Workflowservice\V1\FetchWorkerConfigResponse; +use Temporal\Api\Workflowservice\V1\GetClusterInfoRequest; +use Temporal\Api\Workflowservice\V1\GetClusterInfoResponse; +use Temporal\Api\Workflowservice\V1\GetCurrentDeploymentRequest; +use Temporal\Api\Workflowservice\V1\GetCurrentDeploymentResponse; +use Temporal\Api\Workflowservice\V1\GetDeploymentReachabilityRequest; +use Temporal\Api\Workflowservice\V1\GetDeploymentReachabilityResponse; +use Temporal\Api\Workflowservice\V1\GetSearchAttributesRequest; +use Temporal\Api\Workflowservice\V1\GetSearchAttributesResponse; +use Temporal\Api\Workflowservice\V1\GetSystemInfoRequest; +use Temporal\Api\Workflowservice\V1\GetSystemInfoResponse; +use Temporal\Api\Workflowservice\V1\GetWorkerBuildIdCompatibilityRequest; +use Temporal\Api\Workflowservice\V1\GetWorkerBuildIdCompatibilityResponse; +use Temporal\Api\Workflowservice\V1\GetWorkerTaskReachabilityRequest; +use Temporal\Api\Workflowservice\V1\GetWorkerTaskReachabilityResponse; +use Temporal\Api\Workflowservice\V1\GetWorkerVersioningRulesRequest; +use Temporal\Api\Workflowservice\V1\GetWorkerVersioningRulesResponse; +use Temporal\Api\Workflowservice\V1\GetWorkflowExecutionHistoryRequest; +use Temporal\Api\Workflowservice\V1\GetWorkflowExecutionHistoryResponse; +use Temporal\Api\Workflowservice\V1\GetWorkflowExecutionHistoryReverseRequest; +use Temporal\Api\Workflowservice\V1\GetWorkflowExecutionHistoryReverseResponse; +use Temporal\Api\Workflowservice\V1\ListArchivedWorkflowExecutionsRequest; +use Temporal\Api\Workflowservice\V1\ListArchivedWorkflowExecutionsResponse; +use Temporal\Api\Workflowservice\V1\ListBatchOperationsRequest; +use Temporal\Api\Workflowservice\V1\ListBatchOperationsResponse; +use Temporal\Api\Workflowservice\V1\ListClosedWorkflowExecutionsRequest; +use Temporal\Api\Workflowservice\V1\ListClosedWorkflowExecutionsResponse; +use Temporal\Api\Workflowservice\V1\ListDeploymentsRequest; +use Temporal\Api\Workflowservice\V1\ListDeploymentsResponse; +use Temporal\Api\Workflowservice\V1\ListNamespacesRequest; +use Temporal\Api\Workflowservice\V1\ListNamespacesResponse; +use Temporal\Api\Workflowservice\V1\ListOpenWorkflowExecutionsRequest; +use Temporal\Api\Workflowservice\V1\ListOpenWorkflowExecutionsResponse; +use Temporal\Api\Workflowservice\V1\ListScheduleMatchingTimesRequest; +use Temporal\Api\Workflowservice\V1\ListScheduleMatchingTimesResponse; +use Temporal\Api\Workflowservice\V1\ListSchedulesRequest; +use Temporal\Api\Workflowservice\V1\ListSchedulesResponse; +use Temporal\Api\Workflowservice\V1\ListTaskQueuePartitionsRequest; +use Temporal\Api\Workflowservice\V1\ListTaskQueuePartitionsResponse; +use Temporal\Api\Workflowservice\V1\ListWorkerDeploymentsRequest; +use Temporal\Api\Workflowservice\V1\ListWorkerDeploymentsResponse; +use Temporal\Api\Workflowservice\V1\ListWorkersRequest; +use Temporal\Api\Workflowservice\V1\ListWorkersResponse; +use Temporal\Api\Workflowservice\V1\ListWorkflowExecutionsRequest; +use Temporal\Api\Workflowservice\V1\ListWorkflowExecutionsResponse; +use Temporal\Api\Workflowservice\V1\ListWorkflowRulesRequest; +use Temporal\Api\Workflowservice\V1\ListWorkflowRulesResponse; +use Temporal\Api\Workflowservice\V1\PatchScheduleRequest; +use Temporal\Api\Workflowservice\V1\PatchScheduleResponse; +use Temporal\Api\Workflowservice\V1\PauseActivityRequest; +use Temporal\Api\Workflowservice\V1\PauseActivityResponse; +use Temporal\Api\Workflowservice\V1\PollActivityTaskQueueRequest; +use Temporal\Api\Workflowservice\V1\PollActivityTaskQueueResponse; +use Temporal\Api\Workflowservice\V1\PollNexusTaskQueueRequest; +use Temporal\Api\Workflowservice\V1\PollNexusTaskQueueResponse; +use Temporal\Api\Workflowservice\V1\PollWorkflowExecutionUpdateRequest; +use Temporal\Api\Workflowservice\V1\PollWorkflowExecutionUpdateResponse; +use Temporal\Api\Workflowservice\V1\PollWorkflowTaskQueueRequest; +use Temporal\Api\Workflowservice\V1\PollWorkflowTaskQueueResponse; +use Temporal\Api\Workflowservice\V1\QueryWorkflowRequest; +use Temporal\Api\Workflowservice\V1\QueryWorkflowResponse; +use Temporal\Api\Workflowservice\V1\RecordActivityTaskHeartbeatByIdRequest; +use Temporal\Api\Workflowservice\V1\RecordActivityTaskHeartbeatByIdResponse; +use Temporal\Api\Workflowservice\V1\RecordActivityTaskHeartbeatRequest; +use Temporal\Api\Workflowservice\V1\RecordActivityTaskHeartbeatResponse; +use Temporal\Api\Workflowservice\V1\RecordWorkerHeartbeatRequest; +use Temporal\Api\Workflowservice\V1\RecordWorkerHeartbeatResponse; +use Temporal\Api\Workflowservice\V1\RegisterNamespaceRequest; +use Temporal\Api\Workflowservice\V1\RegisterNamespaceResponse; +use Temporal\Api\Workflowservice\V1\RequestCancelWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\RequestCancelWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\ResetActivityRequest; +use Temporal\Api\Workflowservice\V1\ResetActivityResponse; +use Temporal\Api\Workflowservice\V1\ResetStickyTaskQueueRequest; +use Temporal\Api\Workflowservice\V1\ResetStickyTaskQueueResponse; +use Temporal\Api\Workflowservice\V1\ResetWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\ResetWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCanceledByIdRequest; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCanceledByIdResponse; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCanceledRequest; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCanceledResponse; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCompletedByIdRequest; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCompletedByIdResponse; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCompletedRequest; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskCompletedResponse; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskFailedByIdRequest; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskFailedByIdResponse; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskFailedRequest; +use Temporal\Api\Workflowservice\V1\RespondActivityTaskFailedResponse; +use Temporal\Api\Workflowservice\V1\RespondNexusTaskCompletedRequest; +use Temporal\Api\Workflowservice\V1\RespondNexusTaskCompletedResponse; +use Temporal\Api\Workflowservice\V1\RespondNexusTaskFailedRequest; +use Temporal\Api\Workflowservice\V1\RespondNexusTaskFailedResponse; +use Temporal\Api\Workflowservice\V1\RespondQueryTaskCompletedRequest; +use Temporal\Api\Workflowservice\V1\RespondQueryTaskCompletedResponse; +use Temporal\Api\Workflowservice\V1\RespondWorkflowTaskCompletedRequest; +use Temporal\Api\Workflowservice\V1\RespondWorkflowTaskCompletedResponse; +use Temporal\Api\Workflowservice\V1\RespondWorkflowTaskFailedRequest; +use Temporal\Api\Workflowservice\V1\RespondWorkflowTaskFailedResponse; +use Temporal\Api\Workflowservice\V1\ScanWorkflowExecutionsRequest; +use Temporal\Api\Workflowservice\V1\ScanWorkflowExecutionsResponse; +use Temporal\Api\Workflowservice\V1\SetCurrentDeploymentRequest; +use Temporal\Api\Workflowservice\V1\SetCurrentDeploymentResponse; +use Temporal\Api\Workflowservice\V1\SetWorkerDeploymentCurrentVersionRequest; +use Temporal\Api\Workflowservice\V1\SetWorkerDeploymentCurrentVersionResponse; +use Temporal\Api\Workflowservice\V1\SetWorkerDeploymentManagerRequest; +use Temporal\Api\Workflowservice\V1\SetWorkerDeploymentManagerResponse; +use Temporal\Api\Workflowservice\V1\SetWorkerDeploymentRampingVersionRequest; +use Temporal\Api\Workflowservice\V1\SetWorkerDeploymentRampingVersionResponse; +use Temporal\Api\Workflowservice\V1\ShutdownWorkerRequest; +use Temporal\Api\Workflowservice\V1\ShutdownWorkerResponse; +use Temporal\Api\Workflowservice\V1\SignalWithStartWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\SignalWithStartWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\SignalWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\SignalWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\StartBatchOperationRequest; +use Temporal\Api\Workflowservice\V1\StartBatchOperationResponse; +use Temporal\Api\Workflowservice\V1\StartWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\StartWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\StopBatchOperationRequest; +use Temporal\Api\Workflowservice\V1\StopBatchOperationResponse; +use Temporal\Api\Workflowservice\V1\TerminateWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\TerminateWorkflowExecutionResponse; +use Temporal\Api\Workflowservice\V1\TriggerWorkflowRuleRequest; +use Temporal\Api\Workflowservice\V1\TriggerWorkflowRuleResponse; +use Temporal\Api\Workflowservice\V1\UnpauseActivityRequest; +use Temporal\Api\Workflowservice\V1\UnpauseActivityResponse; +use Temporal\Api\Workflowservice\V1\UpdateActivityOptionsRequest; +use Temporal\Api\Workflowservice\V1\UpdateActivityOptionsResponse; +use Temporal\Api\Workflowservice\V1\UpdateNamespaceRequest; +use Temporal\Api\Workflowservice\V1\UpdateNamespaceResponse; +use Temporal\Api\Workflowservice\V1\UpdateScheduleRequest; +use Temporal\Api\Workflowservice\V1\UpdateScheduleResponse; +use Temporal\Api\Workflowservice\V1\UpdateTaskQueueConfigRequest; +use Temporal\Api\Workflowservice\V1\UpdateTaskQueueConfigResponse; +use Temporal\Api\Workflowservice\V1\UpdateWorkerBuildIdCompatibilityRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkerBuildIdCompatibilityResponse; +use Temporal\Api\Workflowservice\V1\UpdateWorkerConfigRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkerConfigResponse; +use Temporal\Api\Workflowservice\V1\UpdateWorkerDeploymentVersionMetadataRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkerDeploymentVersionMetadataResponse; +use Temporal\Api\Workflowservice\V1\UpdateWorkerVersioningRulesRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkerVersioningRulesResponse; +use Temporal\Api\Workflowservice\V1\UpdateWorkflowExecutionOptionsRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkflowExecutionOptionsResponse; +use Temporal\Api\Workflowservice\V1\UpdateWorkflowExecutionRequest; +use Temporal\Api\Workflowservice\V1\UpdateWorkflowExecutionResponse; use Temporal\Exception\Client\ServiceClientException; +use Temporal\Client\Common\ServerCapabilities; -interface ServiceClientInterface +interface ServiceClientInterface extends GrpcClientInterface { - public function getContext(): ContextInterface; - - public function withContext(ContextInterface $context): static; - - public function withAuthKey(\Stringable|string $key): static; - - public function getConnection(): \Temporal\Client\GRPC\Connection\ConnectionInterface; - - public function getServerCapabilities(): ?\Temporal\Client\Common\ServerCapabilities; + public function getServerCapabilities(): ?ServerCapabilities; /** * RegisterNamespace creates a new namespace which can be used as a container for @@ -33,7 +213,7 @@ public function getServerCapabilities(): ?\Temporal\Client\Common\ServerCapabili * * @throws ServiceClientException */ - public function RegisterNamespace(V1\RegisterNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\RegisterNamespaceResponse; + public function RegisterNamespace(RegisterNamespaceRequest $arg, ?ContextInterface $ctx = null): RegisterNamespaceResponse; /** * DescribeNamespace returns the information and configuration for a registered @@ -41,14 +221,14 @@ public function RegisterNamespace(V1\RegisterNamespaceRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function DescribeNamespace(V1\DescribeNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\DescribeNamespaceResponse; + public function DescribeNamespace(DescribeNamespaceRequest $arg, ?ContextInterface $ctx = null): DescribeNamespaceResponse; /** * ListNamespaces returns the information and configuration for all namespaces. * * @throws ServiceClientException */ - public function ListNamespaces(V1\ListNamespacesRequest $arg, ?ContextInterface $ctx = null): V1\ListNamespacesResponse; + public function ListNamespaces(ListNamespacesRequest $arg, ?ContextInterface $ctx = null): ListNamespacesResponse; /** * UpdateNamespace is used to update the information and configuration of a @@ -57,7 +237,7 @@ public function ListNamespaces(V1\ListNamespacesRequest $arg, ?ContextInterface * * @throws ServiceClientException */ - public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\UpdateNamespaceResponse; + public function UpdateNamespace(UpdateNamespaceRequest $arg, ?ContextInterface $ctx = null): UpdateNamespaceResponse; /** * DeprecateNamespace is used to update the state of a registered namespace to @@ -73,7 +253,7 @@ public function UpdateNamespace(V1\UpdateNamespaceRequest $arg, ?ContextInterfac * * @throws ServiceClientException */ - public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ?ContextInterface $ctx = null): V1\DeprecateNamespaceResponse; + public function DeprecateNamespace(DeprecateNamespaceRequest $arg, ?ContextInterface $ctx = null): DeprecateNamespaceResponse; /** * StartWorkflowExecution starts a new workflow execution. @@ -86,7 +266,7 @@ public function DeprecateNamespace(V1\DeprecateNamespaceRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\StartWorkflowExecutionResponse; + public function StartWorkflowExecution(StartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): StartWorkflowExecutionResponse; /** * ExecuteMultiOperation executes multiple operations within a single workflow. @@ -99,11 +279,9 @@ public function StartWorkflowExecution(V1\StartWorkflowExecutionRequest $arg, ?C * Upon failure, it returns `MultiOperationExecutionFailure` where the status code * equals the status code of the *first* operation that failed to be started. * - * NOTE: Experimental API. - * * @throws ServiceClientException */ - public function ExecuteMultiOperation(V1\ExecuteMultiOperationRequest $arg, ?ContextInterface $ctx = null): V1\ExecuteMultiOperationResponse; + public function ExecuteMultiOperation(ExecuteMultiOperationRequest $arg, ?ContextInterface $ctx = null): ExecuteMultiOperationResponse; /** * GetWorkflowExecutionHistory returns the history of specified workflow execution. @@ -112,7 +290,7 @@ public function ExecuteMultiOperation(V1\ExecuteMultiOperationRequest $arg, ?Con * * @throws ServiceClientException */ - public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryResponse; + public function GetWorkflowExecutionHistory(GetWorkflowExecutionHistoryRequest $arg, ?ContextInterface $ctx = null): GetWorkflowExecutionHistoryResponse; /** * GetWorkflowExecutionHistoryReverse returns the history of specified workflow @@ -123,7 +301,7 @@ public function GetWorkflowExecutionHistory(V1\GetWorkflowExecutionHistoryReques * * @throws ServiceClientException */ - public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistoryReverseRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkflowExecutionHistoryReverseResponse; + public function GetWorkflowExecutionHistoryReverse(GetWorkflowExecutionHistoryReverseRequest $arg, ?ContextInterface $ctx = null): GetWorkflowExecutionHistoryReverseResponse; /** * PollWorkflowTaskQueue is called by workers to make progress on workflows. @@ -141,7 +319,7 @@ public function GetWorkflowExecutionHistoryReverse(V1\GetWorkflowExecutionHistor * * @throws ServiceClientException */ - public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollWorkflowTaskQueueResponse; + public function PollWorkflowTaskQueue(PollWorkflowTaskQueueRequest $arg, ?ContextInterface $ctx = null): PollWorkflowTaskQueueResponse; /** * RespondWorkflowTaskCompleted is called by workers to successfully complete @@ -159,7 +337,7 @@ public function PollWorkflowTaskQueue(V1\PollWorkflowTaskQueueRequest $arg, ?Con * * @throws ServiceClientException */ - public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondWorkflowTaskCompletedResponse; + public function RespondWorkflowTaskCompleted(RespondWorkflowTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondWorkflowTaskCompletedResponse; /** * RespondWorkflowTaskFailed is called by workers to indicate the processing of a @@ -181,7 +359,7 @@ public function RespondWorkflowTaskCompleted(V1\RespondWorkflowTaskCompletedRequ * * @throws ServiceClientException */ - public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondWorkflowTaskFailedResponse; + public function RespondWorkflowTaskFailed(RespondWorkflowTaskFailedRequest $arg, ?ContextInterface $ctx = null): RespondWorkflowTaskFailedResponse; /** * PollActivityTaskQueue is called by workers to process activity tasks from a @@ -209,7 +387,7 @@ public function RespondWorkflowTaskFailed(V1\RespondWorkflowTaskFailedRequest $a * * @throws ServiceClientException */ - public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollActivityTaskQueueResponse; + public function PollActivityTaskQueue(PollActivityTaskQueueRequest $arg, ?ContextInterface $ctx = null): PollActivityTaskQueueResponse; /** * RecordActivityTaskHeartbeat is optionally called by workers while they execute @@ -226,7 +404,7 @@ public function PollActivityTaskQueue(V1\PollActivityTaskQueueRequest $arg, ?Con * * @throws ServiceClientException */ - public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatRequest $arg, ?ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatResponse; + public function RecordActivityTaskHeartbeat(RecordActivityTaskHeartbeatRequest $arg, ?ContextInterface $ctx = null): RecordActivityTaskHeartbeatResponse; /** * See `RecordActivityTaskHeartbeat`. This version allows clients to record @@ -238,7 +416,7 @@ public function RecordActivityTaskHeartbeat(V1\RecordActivityTaskHeartbeatReques * * @throws ServiceClientException */ - public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatByIdRequest $arg, ?ContextInterface $ctx = null): V1\RecordActivityTaskHeartbeatByIdResponse; + public function RecordActivityTaskHeartbeatById(RecordActivityTaskHeartbeatByIdRequest $arg, ?ContextInterface $ctx = null): RecordActivityTaskHeartbeatByIdResponse; /** * RespondActivityTaskCompleted is called by workers when they successfully @@ -254,7 +432,7 @@ public function RecordActivityTaskHeartbeatById(V1\RecordActivityTaskHeartbeatBy * * @throws ServiceClientException */ - public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCompletedResponse; + public function RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCompletedResponse; /** * See `RecordActivityTaskCompleted`. This version allows clients to record @@ -266,7 +444,7 @@ public function RespondActivityTaskCompleted(V1\RespondActivityTaskCompletedRequ * * @throws ServiceClientException */ - public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompletedByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCompletedByIdResponse; + public function RespondActivityTaskCompletedById(RespondActivityTaskCompletedByIdRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCompletedByIdResponse; /** * RespondActivityTaskFailed is called by workers when processing an activity task @@ -281,7 +459,7 @@ public function RespondActivityTaskCompletedById(V1\RespondActivityTaskCompleted * * @throws ServiceClientException */ - public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskFailedResponse; + public function RespondActivityTaskFailed(RespondActivityTaskFailedRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskFailedResponse; /** * See `RecordActivityTaskFailed`. This version allows clients to record failures @@ -293,7 +471,7 @@ public function RespondActivityTaskFailed(V1\RespondActivityTaskFailedRequest $a * * @throws ServiceClientException */ - public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskFailedByIdResponse; + public function RespondActivityTaskFailedById(RespondActivityTaskFailedByIdRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskFailedByIdResponse; /** * RespondActivityTaskFailed is called by workers when processing an activity task @@ -308,7 +486,7 @@ public function RespondActivityTaskFailedById(V1\RespondActivityTaskFailedByIdRe * * @throws ServiceClientException */ - public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCanceledResponse; + public function RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCanceledResponse; /** * See `RecordActivityTaskCanceled`. This version allows clients to record failures @@ -320,7 +498,7 @@ public function RespondActivityTaskCanceled(V1\RespondActivityTaskCanceledReques * * @throws ServiceClientException */ - public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledByIdRequest $arg, ?ContextInterface $ctx = null): V1\RespondActivityTaskCanceledByIdResponse; + public function RespondActivityTaskCanceledById(RespondActivityTaskCanceledByIdRequest $arg, ?ContextInterface $ctx = null): RespondActivityTaskCanceledByIdResponse; /** * RequestCancelWorkflowExecution is called by workers when they want to request @@ -336,7 +514,7 @@ public function RespondActivityTaskCanceledById(V1\RespondActivityTaskCanceledBy * * @throws ServiceClientException */ - public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\RequestCancelWorkflowExecutionResponse; + public function RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): RequestCancelWorkflowExecutionResponse; /** * SignalWorkflowExecution is used to send a signal to a running workflow @@ -348,7 +526,7 @@ public function RequestCancelWorkflowExecution(V1\RequestCancelWorkflowExecution * * @throws ServiceClientException */ - public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\SignalWorkflowExecutionResponse; + public function SignalWorkflowExecution(SignalWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): SignalWorkflowExecutionResponse; /** * SignalWithStartWorkflowExecution is used to ensure a signal is sent to a @@ -369,7 +547,7 @@ public function SignalWorkflowExecution(V1\SignalWorkflowExecutionRequest $arg, * * @throws ServiceClientException */ - public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\SignalWithStartWorkflowExecutionResponse; + public function SignalWithStartWorkflowExecution(SignalWithStartWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): SignalWithStartWorkflowExecutionResponse; /** * ResetWorkflowExecution will reset an existing workflow execution to a specified @@ -381,7 +559,7 @@ public function SignalWithStartWorkflowExecution(V1\SignalWithStartWorkflowExecu * * @throws ServiceClientException */ - public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\ResetWorkflowExecutionResponse; + public function ResetWorkflowExecution(ResetWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): ResetWorkflowExecutionResponse; /** * TerminateWorkflowExecution terminates an existing workflow execution by @@ -392,7 +570,7 @@ public function ResetWorkflowExecution(V1\ResetWorkflowExecutionRequest $arg, ?C * * @throws ServiceClientException */ - public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\TerminateWorkflowExecutionResponse; + public function TerminateWorkflowExecution(TerminateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): TerminateWorkflowExecutionResponse; /** * DeleteWorkflowExecution asynchronously deletes a specific Workflow Execution @@ -408,7 +586,7 @@ public function TerminateWorkflowExecution(V1\TerminateWorkflowExecutionRequest * * @throws ServiceClientException */ - public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkflowExecutionResponse; + public function DeleteWorkflowExecution(DeleteWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): DeleteWorkflowExecutionResponse; /** * ListOpenWorkflowExecutions is a visibility API to list the open executions in a @@ -419,7 +597,7 @@ public function DeleteWorkflowExecution(V1\DeleteWorkflowExecutionRequest $arg, * * @throws ServiceClientException */ - public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListOpenWorkflowExecutionsResponse; + public function ListOpenWorkflowExecutions(ListOpenWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListOpenWorkflowExecutionsResponse; /** * ListClosedWorkflowExecutions is a visibility API to list the closed executions @@ -430,7 +608,7 @@ public function ListOpenWorkflowExecutions(V1\ListOpenWorkflowExecutionsRequest * * @throws ServiceClientException */ - public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListClosedWorkflowExecutionsResponse; + public function ListClosedWorkflowExecutions(ListClosedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListClosedWorkflowExecutionsResponse; /** * ListWorkflowExecutions is a visibility API to list workflow executions in a @@ -438,7 +616,7 @@ public function ListClosedWorkflowExecutions(V1\ListClosedWorkflowExecutionsRequ * * @throws ServiceClientException */ - public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkflowExecutionsResponse; + public function ListWorkflowExecutions(ListWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListWorkflowExecutionsResponse; /** * ListArchivedWorkflowExecutions is a visibility API to list archived workflow @@ -446,11 +624,13 @@ public function ListWorkflowExecutions(V1\ListWorkflowExecutionsRequest $arg, ?C * * @throws ServiceClientException */ - public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ListArchivedWorkflowExecutionsResponse; + public function ListArchivedWorkflowExecutions(ListArchivedWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ListArchivedWorkflowExecutionsResponse; /** - * ScanWorkflowExecutions is a visibility API to list large amount of workflow + * ScanWorkflowExecutions _was_ a visibility API to list large amount of workflow * executions in a specific namespace without order. + * It has since been deprecated in favor of `ListWorkflowExecutions` and rewritten + * to use `ListWorkflowExecutions` internally. * * Deprecated: Replaced with `ListWorkflowExecutions`. * (-- api-linter: core::0127::http-annotation=disabled @@ -458,7 +638,7 @@ public function ListArchivedWorkflowExecutions(V1\ListArchivedWorkflowExecutions * * @throws ServiceClientException */ - public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\ScanWorkflowExecutionsResponse; + public function ScanWorkflowExecutions(ScanWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): ScanWorkflowExecutionsResponse; /** * CountWorkflowExecutions is a visibility API to count of workflow executions in a @@ -466,7 +646,7 @@ public function ScanWorkflowExecutions(V1\ScanWorkflowExecutionsRequest $arg, ?C * * @throws ServiceClientException */ - public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): V1\CountWorkflowExecutionsResponse; + public function CountWorkflowExecutions(CountWorkflowExecutionsRequest $arg, ?ContextInterface $ctx = null): CountWorkflowExecutionsResponse; /** * GetSearchAttributes is a visibility API to get all legal keys that could be used @@ -478,7 +658,7 @@ public function CountWorkflowExecutions(V1\CountWorkflowExecutionsRequest $arg, * * @throws ServiceClientException */ - public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ?ContextInterface $ctx = null): V1\GetSearchAttributesResponse; + public function GetSearchAttributes(GetSearchAttributesRequest $arg, ?ContextInterface $ctx = null): GetSearchAttributesResponse; /** * RespondQueryTaskCompleted is called by workers to complete queries which were @@ -494,7 +674,7 @@ public function GetSearchAttributes(V1\GetSearchAttributesRequest $arg, ?Context * * @throws ServiceClientException */ - public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondQueryTaskCompletedResponse; + public function RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondQueryTaskCompletedResponse; /** * ResetStickyTaskQueue resets the sticky task queue related information in the @@ -516,7 +696,7 @@ public function RespondQueryTaskCompleted(V1\RespondQueryTaskCompletedRequest $a * * @throws ServiceClientException */ - public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\ResetStickyTaskQueueResponse; + public function ResetStickyTaskQueue(ResetStickyTaskQueueRequest $arg, ?ContextInterface $ctx = null): ResetStickyTaskQueueResponse; /** * ShutdownWorker is used to indicate that the given sticky task @@ -535,14 +715,14 @@ public function ResetStickyTaskQueue(V1\ResetStickyTaskQueueRequest $arg, ?Conte * * @throws ServiceClientException */ - public function ShutdownWorker(V1\ShutdownWorkerRequest $arg, ?ContextInterface $ctx = null): V1\ShutdownWorkerResponse; + public function ShutdownWorker(ShutdownWorkerRequest $arg, ?ContextInterface $ctx = null): ShutdownWorkerResponse; /** * QueryWorkflow requests a query be executed for a specified workflow execution. * * @throws ServiceClientException */ - public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ?ContextInterface $ctx = null): V1\QueryWorkflowResponse; + public function QueryWorkflow(QueryWorkflowRequest $arg, ?ContextInterface $ctx = null): QueryWorkflowResponse; /** * DescribeWorkflowExecution returns information about the specified workflow @@ -550,7 +730,7 @@ public function QueryWorkflow(V1\QueryWorkflowRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkflowExecutionResponse; + public function DescribeWorkflowExecution(DescribeWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): DescribeWorkflowExecutionResponse; /** * DescribeTaskQueue returns the following information about the target task queue, @@ -561,21 +741,21 @@ public function DescribeWorkflowExecution(V1\DescribeWorkflowExecutionRequest $a * * @throws ServiceClientException */ - public function DescribeTaskQueue(V1\DescribeTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\DescribeTaskQueueResponse; + public function DescribeTaskQueue(DescribeTaskQueueRequest $arg, ?ContextInterface $ctx = null): DescribeTaskQueueResponse; /** * GetClusterInfo returns information about temporal cluster * * @throws ServiceClientException */ - public function GetClusterInfo(V1\GetClusterInfoRequest $arg, ?ContextInterface $ctx = null): V1\GetClusterInfoResponse; + public function GetClusterInfo(GetClusterInfoRequest $arg, ?ContextInterface $ctx = null): GetClusterInfoResponse; /** * GetSystemInfo returns information about the system. * * @throws ServiceClientException */ - public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ?ContextInterface $ctx = null): V1\GetSystemInfoResponse; + public function GetSystemInfo(GetSystemInfoRequest $arg, ?ContextInterface $ctx = null): GetSystemInfoResponse; /** * (-- api-linter: core::0127::http-annotation=disabled @@ -583,56 +763,56 @@ public function GetSystemInfo(V1\GetSystemInfoRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function ListTaskQueuePartitions(V1\ListTaskQueuePartitionsRequest $arg, ?ContextInterface $ctx = null): V1\ListTaskQueuePartitionsResponse; + public function ListTaskQueuePartitions(ListTaskQueuePartitionsRequest $arg, ?ContextInterface $ctx = null): ListTaskQueuePartitionsResponse; /** * Creates a new schedule. * * @throws ServiceClientException */ - public function CreateSchedule(V1\CreateScheduleRequest $arg, ?ContextInterface $ctx = null): V1\CreateScheduleResponse; + public function CreateSchedule(CreateScheduleRequest $arg, ?ContextInterface $ctx = null): CreateScheduleResponse; /** * Returns the schedule description and current state of an existing schedule. * * @throws ServiceClientException */ - public function DescribeSchedule(V1\DescribeScheduleRequest $arg, ?ContextInterface $ctx = null): V1\DescribeScheduleResponse; + public function DescribeSchedule(DescribeScheduleRequest $arg, ?ContextInterface $ctx = null): DescribeScheduleResponse; /** * Changes the configuration or state of an existing schedule. * * @throws ServiceClientException */ - public function UpdateSchedule(V1\UpdateScheduleRequest $arg, ?ContextInterface $ctx = null): V1\UpdateScheduleResponse; + public function UpdateSchedule(UpdateScheduleRequest $arg, ?ContextInterface $ctx = null): UpdateScheduleResponse; /** * Makes a specific change to a schedule or triggers an immediate action. * * @throws ServiceClientException */ - public function PatchSchedule(V1\PatchScheduleRequest $arg, ?ContextInterface $ctx = null): V1\PatchScheduleResponse; + public function PatchSchedule(PatchScheduleRequest $arg, ?ContextInterface $ctx = null): PatchScheduleResponse; /** * Lists matching times within a range. * * @throws ServiceClientException */ - public function ListScheduleMatchingTimes(V1\ListScheduleMatchingTimesRequest $arg, ?ContextInterface $ctx = null): V1\ListScheduleMatchingTimesResponse; + public function ListScheduleMatchingTimes(ListScheduleMatchingTimesRequest $arg, ?ContextInterface $ctx = null): ListScheduleMatchingTimesResponse; /** * Deletes a schedule, removing it from the system. * * @throws ServiceClientException */ - public function DeleteSchedule(V1\DeleteScheduleRequest $arg, ?ContextInterface $ctx = null): V1\DeleteScheduleResponse; + public function DeleteSchedule(DeleteScheduleRequest $arg, ?ContextInterface $ctx = null): DeleteScheduleResponse; /** * List all schedules in a namespace. * * @throws ServiceClientException */ - public function ListSchedules(V1\ListSchedulesRequest $arg, ?ContextInterface $ctx = null): V1\ListSchedulesResponse; + public function ListSchedules(ListSchedulesRequest $arg, ?ContextInterface $ctx = null): ListSchedulesResponse; /** * Deprecated. Use `UpdateWorkerVersioningRules`. @@ -661,7 +841,7 @@ public function ListSchedules(V1\ListSchedulesRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerBuildIdCompatibilityResponse; + public function UpdateWorkerBuildIdCompatibility(UpdateWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerBuildIdCompatibilityResponse; /** * Deprecated. Use `GetWorkerVersioningRules`. @@ -669,7 +849,7 @@ public function UpdateWorkerBuildIdCompatibility(V1\UpdateWorkerBuildIdCompatibi * * @throws ServiceClientException */ - public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerBuildIdCompatibilityResponse; + public function GetWorkerBuildIdCompatibility(GetWorkerBuildIdCompatibilityRequest $arg, ?ContextInterface $ctx = null): GetWorkerBuildIdCompatibilityResponse; /** * Use this API to manage Worker Versioning Rules for a given Task Queue. There are @@ -713,7 +893,7 @@ public function GetWorkerBuildIdCompatibility(V1\GetWorkerBuildIdCompatibilityRe * * @throws ServiceClientException */ - public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerVersioningRulesResponse; + public function UpdateWorkerVersioningRules(UpdateWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerVersioningRulesResponse; /** * Fetches the Build ID assignment and redirect rules for a Task Queue. @@ -722,7 +902,7 @@ public function UpdateWorkerVersioningRules(V1\UpdateWorkerVersioningRulesReques * * @throws ServiceClientException */ - public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerVersioningRulesResponse; + public function GetWorkerVersioningRules(GetWorkerVersioningRulesRequest $arg, ?ContextInterface $ctx = null): GetWorkerVersioningRulesResponse; /** * Deprecated. Use `DescribeTaskQueue`. @@ -749,7 +929,7 @@ public function GetWorkerVersioningRules(V1\GetWorkerVersioningRulesRequest $arg * * @throws ServiceClientException */ - public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $arg, ?ContextInterface $ctx = null): V1\GetWorkerTaskReachabilityResponse; + public function GetWorkerTaskReachability(GetWorkerTaskReachabilityRequest $arg, ?ContextInterface $ctx = null): GetWorkerTaskReachabilityResponse; /** * Describes a worker deployment. @@ -757,14 +937,14 @@ public function GetWorkerTaskReachability(V1\GetWorkerTaskReachabilityRequest $a * * @throws ServiceClientException */ - public function DescribeDeployment(V1\DescribeDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\DescribeDeploymentResponse; + public function DescribeDeployment(DescribeDeploymentRequest $arg, ?ContextInterface $ctx = null): DescribeDeploymentResponse; /** * Describes a worker deployment version. * * @throws ServiceClientException */ - public function DescribeWorkerDeploymentVersion(V1\DescribeWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkerDeploymentVersionResponse; + public function DescribeWorkerDeploymentVersion(DescribeWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): DescribeWorkerDeploymentVersionResponse; /** * Lists worker deployments in the namespace. Optionally can filter based on @@ -774,7 +954,7 @@ public function DescribeWorkerDeploymentVersion(V1\DescribeWorkerDeploymentVersi * * @throws ServiceClientException */ - public function ListDeployments(V1\ListDeploymentsRequest $arg, ?ContextInterface $ctx = null): V1\ListDeploymentsResponse; + public function ListDeployments(ListDeploymentsRequest $arg, ?ContextInterface $ctx = null): ListDeploymentsResponse; /** * Returns the reachability level of a worker deployment to help users decide when @@ -793,7 +973,7 @@ public function ListDeployments(V1\ListDeploymentsRequest $arg, ?ContextInterfac * * @throws ServiceClientException */ - public function GetDeploymentReachability(V1\GetDeploymentReachabilityRequest $arg, ?ContextInterface $ctx = null): V1\GetDeploymentReachabilityResponse; + public function GetDeploymentReachability(GetDeploymentReachabilityRequest $arg, ?ContextInterface $ctx = null): GetDeploymentReachabilityResponse; /** * Returns the current deployment (and its info) for a given deployment series. @@ -802,7 +982,7 @@ public function GetDeploymentReachability(V1\GetDeploymentReachabilityRequest $a * * @throws ServiceClientException */ - public function GetCurrentDeployment(V1\GetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\GetCurrentDeploymentResponse; + public function GetCurrentDeployment(GetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): GetCurrentDeploymentResponse; /** * Sets a deployment as the current deployment for its deployment series. Can @@ -812,7 +992,7 @@ public function GetCurrentDeployment(V1\GetCurrentDeploymentRequest $arg, ?Conte * * @throws ServiceClientException */ - public function SetCurrentDeployment(V1\SetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\SetCurrentDeploymentResponse; + public function SetCurrentDeployment(SetCurrentDeploymentRequest $arg, ?ContextInterface $ctx = null): SetCurrentDeploymentResponse; /** * Set/unset the Current Version of a Worker Deployment. Automatically unsets the @@ -821,14 +1001,14 @@ public function SetCurrentDeployment(V1\SetCurrentDeploymentRequest $arg, ?Conte * * @throws ServiceClientException */ - public function SetWorkerDeploymentCurrentVersion(V1\SetWorkerDeploymentCurrentVersionRequest $arg, ?ContextInterface $ctx = null): V1\SetWorkerDeploymentCurrentVersionResponse; + public function SetWorkerDeploymentCurrentVersion(SetWorkerDeploymentCurrentVersionRequest $arg, ?ContextInterface $ctx = null): SetWorkerDeploymentCurrentVersionResponse; /** * Describes a Worker Deployment. * * @throws ServiceClientException */ - public function DescribeWorkerDeployment(V1\DescribeWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkerDeploymentResponse; + public function DescribeWorkerDeployment(DescribeWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): DescribeWorkerDeploymentResponse; /** * Deletes records of (an old) Deployment. A deployment can only be deleted if @@ -836,7 +1016,7 @@ public function DescribeWorkerDeployment(V1\DescribeWorkerDeploymentRequest $arg * * @throws ServiceClientException */ - public function DeleteWorkerDeployment(V1\DeleteWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkerDeploymentResponse; + public function DeleteWorkerDeployment(DeleteWorkerDeploymentRequest $arg, ?ContextInterface $ctx = null): DeleteWorkerDeploymentResponse; /** * Used for manual deletion of Versions. User can delete a Version only when all @@ -850,7 +1030,7 @@ public function DeleteWorkerDeployment(V1\DeleteWorkerDeploymentRequest $arg, ?C * * @throws ServiceClientException */ - public function DeleteWorkerDeploymentVersion(V1\DeleteWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkerDeploymentVersionResponse; + public function DeleteWorkerDeploymentVersion(DeleteWorkerDeploymentVersionRequest $arg, ?ContextInterface $ctx = null): DeleteWorkerDeploymentVersionResponse; /** * Set/unset the Ramping Version of a Worker Deployment and its ramp percentage. @@ -859,28 +1039,35 @@ public function DeleteWorkerDeploymentVersion(V1\DeleteWorkerDeploymentVersionRe * * @throws ServiceClientException */ - public function SetWorkerDeploymentRampingVersion(V1\SetWorkerDeploymentRampingVersionRequest $arg, ?ContextInterface $ctx = null): V1\SetWorkerDeploymentRampingVersionResponse; + public function SetWorkerDeploymentRampingVersion(SetWorkerDeploymentRampingVersionRequest $arg, ?ContextInterface $ctx = null): SetWorkerDeploymentRampingVersionResponse; /** * Lists all Worker Deployments that are tracked in the Namespace. * * @throws ServiceClientException */ - public function ListWorkerDeployments(V1\ListWorkerDeploymentsRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkerDeploymentsResponse; + public function ListWorkerDeployments(ListWorkerDeploymentsRequest $arg, ?ContextInterface $ctx = null): ListWorkerDeploymentsResponse; /** * Updates the user-given metadata attached to a Worker Deployment Version. * * @throws ServiceClientException */ - public function UpdateWorkerDeploymentVersionMetadata(V1\UpdateWorkerDeploymentVersionMetadataRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerDeploymentVersionMetadataResponse; + public function UpdateWorkerDeploymentVersionMetadata(UpdateWorkerDeploymentVersionMetadataRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerDeploymentVersionMetadataResponse; + + /** + * Set/unset the ManagerIdentity of a Worker Deployment. + * + * @throws ServiceClientException + */ + public function SetWorkerDeploymentManager(SetWorkerDeploymentManagerRequest $arg, ?ContextInterface $ctx = null): SetWorkerDeploymentManagerResponse; /** * Invokes the specified Update function on user Workflow code. * * @throws ServiceClientException */ - public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkflowExecutionResponse; + public function UpdateWorkflowExecution(UpdateWorkflowExecutionRequest $arg, ?ContextInterface $ctx = null): UpdateWorkflowExecutionResponse; /** * Polls a Workflow Execution for the outcome of a Workflow Update @@ -894,35 +1081,35 @@ public function UpdateWorkflowExecution(V1\UpdateWorkflowExecutionRequest $arg, * * @throws ServiceClientException */ - public function PollWorkflowExecutionUpdate(V1\PollWorkflowExecutionUpdateRequest $arg, ?ContextInterface $ctx = null): V1\PollWorkflowExecutionUpdateResponse; + public function PollWorkflowExecutionUpdate(PollWorkflowExecutionUpdateRequest $arg, ?ContextInterface $ctx = null): PollWorkflowExecutionUpdateResponse; /** * StartBatchOperation starts a new batch operation * * @throws ServiceClientException */ - public function StartBatchOperation(V1\StartBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\StartBatchOperationResponse; + public function StartBatchOperation(StartBatchOperationRequest $arg, ?ContextInterface $ctx = null): StartBatchOperationResponse; /** * StopBatchOperation stops a batch operation * * @throws ServiceClientException */ - public function StopBatchOperation(V1\StopBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\StopBatchOperationResponse; + public function StopBatchOperation(StopBatchOperationRequest $arg, ?ContextInterface $ctx = null): StopBatchOperationResponse; /** * DescribeBatchOperation returns the information about a batch operation * * @throws ServiceClientException */ - public function DescribeBatchOperation(V1\DescribeBatchOperationRequest $arg, ?ContextInterface $ctx = null): V1\DescribeBatchOperationResponse; + public function DescribeBatchOperation(DescribeBatchOperationRequest $arg, ?ContextInterface $ctx = null): DescribeBatchOperationResponse; /** * ListBatchOperations returns a list of batch operations * * @throws ServiceClientException */ - public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ?ContextInterface $ctx = null): V1\ListBatchOperationsResponse; + public function ListBatchOperations(ListBatchOperationsRequest $arg, ?ContextInterface $ctx = null): ListBatchOperationsResponse; /** * PollNexusTaskQueue is a long poll call used by workers to receive Nexus tasks. @@ -931,7 +1118,7 @@ public function ListBatchOperations(V1\ListBatchOperationsRequest $arg, ?Context * * @throws ServiceClientException */ - public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ?ContextInterface $ctx = null): V1\PollNexusTaskQueueResponse; + public function PollNexusTaskQueue(PollNexusTaskQueueRequest $arg, ?ContextInterface $ctx = null): PollNexusTaskQueueResponse; /** * RespondNexusTaskCompleted is called by workers to respond to Nexus tasks @@ -941,7 +1128,7 @@ public function PollNexusTaskQueue(V1\PollNexusTaskQueueRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $arg, ?ContextInterface $ctx = null): V1\RespondNexusTaskCompletedResponse; + public function RespondNexusTaskCompleted(RespondNexusTaskCompletedRequest $arg, ?ContextInterface $ctx = null): RespondNexusTaskCompletedResponse; /** * RespondNexusTaskFailed is called by workers to fail Nexus tasks received via @@ -951,7 +1138,7 @@ public function RespondNexusTaskCompleted(V1\RespondNexusTaskCompletedRequest $a * * @throws ServiceClientException */ - public function RespondNexusTaskFailed(V1\RespondNexusTaskFailedRequest $arg, ?ContextInterface $ctx = null): V1\RespondNexusTaskFailedResponse; + public function RespondNexusTaskFailed(RespondNexusTaskFailedRequest $arg, ?ContextInterface $ctx = null): RespondNexusTaskFailedResponse; /** * UpdateActivityOptions is called by the client to update the options of an @@ -961,7 +1148,7 @@ public function RespondNexusTaskFailed(V1\RespondNexusTaskFailedRequest $arg, ?C * * @throws ServiceClientException */ - public function UpdateActivityOptions(V1\UpdateActivityOptionsRequest $arg, ?ContextInterface $ctx = null): V1\UpdateActivityOptionsResponse; + public function UpdateActivityOptions(UpdateActivityOptionsRequest $arg, ?ContextInterface $ctx = null): UpdateActivityOptionsResponse; /** * UpdateWorkflowExecutionOptions partially updates the WorkflowExecutionOptions of @@ -969,7 +1156,7 @@ public function UpdateActivityOptions(V1\UpdateActivityOptionsRequest $arg, ?Con * * @throws ServiceClientException */ - public function UpdateWorkflowExecutionOptions(V1\UpdateWorkflowExecutionOptionsRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkflowExecutionOptionsResponse; + public function UpdateWorkflowExecutionOptions(UpdateWorkflowExecutionOptionsRequest $arg, ?ContextInterface $ctx = null): UpdateWorkflowExecutionOptionsResponse; /** * PauseActivity pauses the execution of an activity specified by its ID or type. @@ -996,7 +1183,7 @@ public function UpdateWorkflowExecutionOptions(V1\UpdateWorkflowExecutionOptions * * @throws ServiceClientException */ - public function PauseActivity(V1\PauseActivityRequest $arg, ?ContextInterface $ctx = null): V1\PauseActivityResponse; + public function PauseActivity(PauseActivityRequest $arg, ?ContextInterface $ctx = null): PauseActivityResponse; /** * UnpauseActivity unpauses the execution of an activity specified by its ID or @@ -1020,7 +1207,7 @@ public function PauseActivity(V1\PauseActivityRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function UnpauseActivity(V1\UnpauseActivityRequest $arg, ?ContextInterface $ctx = null): V1\UnpauseActivityResponse; + public function UnpauseActivity(UnpauseActivityRequest $arg, ?ContextInterface $ctx = null): UnpauseActivityResponse; /** * ResetActivity resets the execution of an activity specified by its ID or type. @@ -1048,7 +1235,7 @@ public function UnpauseActivity(V1\UnpauseActivityRequest $arg, ?ContextInterfac * * @throws ServiceClientException */ - public function ResetActivity(V1\ResetActivityRequest $arg, ?ContextInterface $ctx = null): V1\ResetActivityResponse; + public function ResetActivity(ResetActivityRequest $arg, ?ContextInterface $ctx = null): ResetActivityResponse; /** * Create a new workflow rule. The rules are used to control the workflow @@ -1061,7 +1248,7 @@ public function ResetActivity(V1\ResetActivityRequest $arg, ?ContextInterface $c * * @throws ServiceClientException */ - public function CreateWorkflowRule(V1\CreateWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\CreateWorkflowRuleResponse; + public function CreateWorkflowRule(CreateWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): CreateWorkflowRuleResponse; /** * DescribeWorkflowRule return the rule specification for existing rule id. @@ -1069,21 +1256,21 @@ public function CreateWorkflowRule(V1\CreateWorkflowRuleRequest $arg, ?ContextIn * * @throws ServiceClientException */ - public function DescribeWorkflowRule(V1\DescribeWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\DescribeWorkflowRuleResponse; + public function DescribeWorkflowRule(DescribeWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): DescribeWorkflowRuleResponse; /** * Delete rule by rule id * * @throws ServiceClientException */ - public function DeleteWorkflowRule(V1\DeleteWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\DeleteWorkflowRuleResponse; + public function DeleteWorkflowRule(DeleteWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): DeleteWorkflowRuleResponse; /** * Return all namespace workflow rules * * @throws ServiceClientException */ - public function ListWorkflowRules(V1\ListWorkflowRulesRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkflowRulesResponse; + public function ListWorkflowRules(ListWorkflowRulesRequest $arg, ?ContextInterface $ctx = null): ListWorkflowRulesResponse; /** * TriggerWorkflowRule allows to: @@ -1093,14 +1280,14 @@ public function ListWorkflowRules(V1\ListWorkflowRulesRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function TriggerWorkflowRule(V1\TriggerWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): V1\TriggerWorkflowRuleResponse; + public function TriggerWorkflowRule(TriggerWorkflowRuleRequest $arg, ?ContextInterface $ctx = null): TriggerWorkflowRuleResponse; /** * WorkerHeartbeat receive heartbeat request from the worker. * * @throws ServiceClientException */ - public function RecordWorkerHeartbeat(V1\RecordWorkerHeartbeatRequest $arg, ?ContextInterface $ctx = null): V1\RecordWorkerHeartbeatResponse; + public function RecordWorkerHeartbeat(RecordWorkerHeartbeatRequest $arg, ?ContextInterface $ctx = null): RecordWorkerHeartbeatResponse; /** * ListWorkers is a visibility API to list worker status information in a specific @@ -1108,7 +1295,7 @@ public function RecordWorkerHeartbeat(V1\RecordWorkerHeartbeatRequest $arg, ?Con * * @throws ServiceClientException */ - public function ListWorkers(V1\ListWorkersRequest $arg, ?ContextInterface $ctx = null): V1\ListWorkersResponse; + public function ListWorkers(ListWorkersRequest $arg, ?ContextInterface $ctx = null): ListWorkersResponse; /** * Updates task queue configuration. @@ -1120,14 +1307,14 @@ public function ListWorkers(V1\ListWorkersRequest $arg, ?ContextInterface $ctx = * * @throws ServiceClientException */ - public function UpdateTaskQueueConfig(V1\UpdateTaskQueueConfigRequest $arg, ?ContextInterface $ctx = null): V1\UpdateTaskQueueConfigResponse; + public function UpdateTaskQueueConfig(UpdateTaskQueueConfigRequest $arg, ?ContextInterface $ctx = null): UpdateTaskQueueConfigResponse; /** * FetchWorkerConfig returns the worker configuration for a specific worker. * * @throws ServiceClientException */ - public function FetchWorkerConfig(V1\FetchWorkerConfigRequest $arg, ?ContextInterface $ctx = null): V1\FetchWorkerConfigResponse; + public function FetchWorkerConfig(FetchWorkerConfigRequest $arg, ?ContextInterface $ctx = null): FetchWorkerConfigResponse; /** * UpdateWorkerConfig updates the worker configuration of one or more workers. @@ -1136,10 +1323,12 @@ public function FetchWorkerConfig(V1\FetchWorkerConfigRequest $arg, ?ContextInte * * @throws ServiceClientException */ - public function UpdateWorkerConfig(V1\UpdateWorkerConfigRequest $arg, ?ContextInterface $ctx = null): V1\UpdateWorkerConfigResponse; + public function UpdateWorkerConfig(UpdateWorkerConfigRequest $arg, ?ContextInterface $ctx = null): UpdateWorkerConfigResponse; /** - * Close the communication channel associated with this stub. + * DescribeWorker returns information about the specified worker. + * + * @throws ServiceClientException */ - public function close(): void; + public function DescribeWorker(DescribeWorkerRequest $arg, ?ContextInterface $ctx = null): DescribeWorkerResponse; } diff --git a/src/Internal/Activity/ActivityContext.php b/src/Internal/Activity/ActivityContext.php index e9e92e758..0acb067da 100644 --- a/src/Internal/Activity/ActivityContext.php +++ b/src/Internal/Activity/ActivityContext.php @@ -127,8 +127,10 @@ public function heartbeat(mixed $details): void ], ); - $cancelled = (bool) ($response['canceled'] ?? false); - $paused = (bool) ($response['paused'] ?? false); + \is_object($response) and $response = (array) $response; + + $cancelled = $this->readHeartbeatFlag($response, 'canceled', 'cancel_requested', 'cancelRequested'); + $paused = $this->readHeartbeatFlag($response, 'paused', 'activity_paused', 'activityPaused'); if ($cancelled || $paused) { $this->cancellationDetails ??= new ActivityCancellationDetails( @@ -171,4 +173,19 @@ public function withInstance(object $instance): self $clone->instance = \WeakReference::create($instance); return $clone; } + + private function readHeartbeatFlag(mixed $response, string ...$keys): bool + { + if (!\is_array($response)) { + return false; + } + + foreach ($keys as $key) { + if (\array_key_exists($key, $response)) { + return (bool) $response[$key]; + } + } + + return false; + } } diff --git a/src/Internal/Transport/Router/StartWorkflow.php b/src/Internal/Transport/Router/StartWorkflow.php index 97edf8b25..90e10b9ed 100644 --- a/src/Internal/Transport/Router/StartWorkflow.php +++ b/src/Internal/Transport/Router/StartWorkflow.php @@ -114,8 +114,9 @@ private function convertSearchAttributes(?array $param): ?EncodedCollection try { $sa = (new SearchAttributes()); + $json = \json_encode($param); $sa->mergeFromJsonString( - \json_encode($param), + $json === false ? '{}' : $json, true, ); @@ -140,8 +141,9 @@ private function convertMemo(?array $param): ?EncodedCollection try { $memo = (new Memo()); + $json = \json_encode($param); $memo->mergeFromJsonString( - \json_encode($param), + $json === false ? '{}' : $json, true, ); diff --git a/src/Worker/Transport/Codec/ProtoCodec.php b/src/Worker/Transport/Codec/ProtoCodec.php index 3c1c6a9db..343c55946 100644 --- a/src/Worker/Transport/Codec/ProtoCodec.php +++ b/src/Worker/Transport/Codec/ProtoCodec.php @@ -48,6 +48,7 @@ public function encode(iterable $commands): string $frame->setMessages($messages); + /** @var non-empty-string */ return $frame->serializeToString(); } catch (\Throwable $e) { throw new ProtocolException($e->getMessage(), $e->getCode(), $e); diff --git a/testing/src/WithoutTimeSkipping.php b/testing/src/WithoutTimeSkipping.php index 34a9d151b..e609c1b29 100644 --- a/testing/src/WithoutTimeSkipping.php +++ b/testing/src/WithoutTimeSkipping.php @@ -4,22 +4,41 @@ namespace Temporal\Testing; +use Temporal\Client\GRPC\StatusCode; +use Temporal\Exception\Client\ServiceClientException; + trait WithoutTimeSkipping { - private TestService $testService; + private ?TestService $testService = null; + private bool $managesTimeSkipping = false; protected function setUp(): void { + $this->managesTimeSkipping = false; $this->testService = TestService::create( \getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233', ); - $this->testService->lockTimeSkipping(); + + try { + $this->testService->lockTimeSkipping(); + $this->managesTimeSkipping = true; + } catch (ServiceClientException $e) { + if ($e->getCode() !== StatusCode::UNIMPLEMENTED) { + throw $e; + } + + $this->testService = null; + } + parent::setUp(); } protected function tearDown(): void { - $this->testService->unlockTimeSkipping(); + if ($this->managesTimeSkipping && $this->testService !== null) { + $this->testService->unlockTimeSkipping(); + } + parent::tearDown(); } } diff --git a/tests/Acceptance/Extra/Activity/ActivityPausedTest.php b/tests/Acceptance/Extra/Activity/ActivityPausedTest.php index acf2edcf5..aa2b0b6a0 100644 --- a/tests/Acceptance/Extra/Activity/ActivityPausedTest.php +++ b/tests/Acceptance/Extra/Activity/ActivityPausedTest.php @@ -7,9 +7,10 @@ use PHPUnit\Framework\Attributes\Test; use Temporal\Activity; use Temporal\Api\Common\V1\WorkflowExecution; +use Temporal\Api\Enums\V1\PendingActivityState; +use Temporal\Api\Workflowservice\V1\DescribeWorkflowExecutionRequest; use Temporal\Api\Workflowservice\V1\PauseActivityRequest; use Temporal\Client\GRPC\ServiceClientInterface; -use Temporal\Client\WorkflowClientInterface; use Temporal\Client\WorkflowStubInterface; use Temporal\Exception\Client\ActivityPausedException; use Temporal\Tests\Acceptance\App\Attribute\Stub; @@ -24,34 +25,42 @@ class ActivityPausedTest extends TestCase public function simplePause( #[Stub('Extra_Activity_ActivityPaused', executionTimeout: '200 seconds')] WorkflowStubInterface $stub, ServiceClientInterface $serviceClient, - WorkflowClientInterface $workflowClient, ): void { - $deadline = \microtime(true) + 10; - find: - $found = false; - foreach ($workflowClient->getWorkflowHistory($stub->getExecution()) as $event) { - if ($event->hasActivityTaskScheduledEventAttributes()) { - $found = true; - break; + $request = (new DescribeWorkflowExecutionRequest()) + ->setNamespace('default') + ->setExecution( + (new WorkflowExecution()) + ->setWorkflowId($stub->getExecution()->getID()) + ->setRunId($stub->getExecution()->getRunID()), + ); + + $deadline = \microtime(true) + 30; + $activityId = null; + while (\microtime(true) < $deadline) { + $description = $serviceClient->DescribeWorkflowExecution($request); + foreach ($description->getPendingActivities() as $pendingActivity) { + if ( + $pendingActivity->getActivityType()?->getName() !== 'Extra_Activity_ActivityPaused.sleep' + || $pendingActivity->getState() !== PendingActivityState::PENDING_ACTIVITY_STATE_STARTED + ) { + continue; + } + + $activityId = $pendingActivity->getActivityId(); + break 2; } - } - if (!$found && \microtime(true) < $deadline) { - goto find; + \usleep(100_000); } - self::assertTrue($found, '`Activity task started` event not found in workflow history'); + self::assertNotNull($activityId, 'Started activity not found for workflow execution'); $serviceClient->PauseActivity( (new PauseActivityRequest()) ->setReason('test') ->setNamespace('default') - ->setType('Extra_Activity_ActivityPaused.sleep') - ->setExecution( - (new WorkflowExecution()) - ->setWorkflowId($stub->getExecution()->getID()) - ->setRunId($stub->getExecution()->getRunID()), - ), + ->setId($activityId) + ->setExecution($request->getExecution()), ); $result = $stub->getResult(timeout: 200); @@ -67,7 +76,9 @@ class TestWorkflow public function handle() { $stub = Workflow::newUntypedActivityStub( - Activity\ActivityOptions::new()->withScheduleToCloseTimeout('101 seconds'), + Activity\ActivityOptions::new() + ->withScheduleToCloseTimeout('101 seconds') + ->withHeartbeatTimeout('5 seconds'), ); /** @see TestActivity::sleep() */ diff --git a/tests/Arch/ArchTest.php b/tests/Arch/ArchTest.php index 112b3ba26..1824a03fe 100644 --- a/tests/Arch/ArchTest.php +++ b/tests/Arch/ArchTest.php @@ -4,37 +4,144 @@ namespace Temporal\Tests\Arch; -use PHPUnit\Architecture\ArchitectureAsserts; use PHPUnit\Framework\TestCase; final class ArchTest extends TestCase { - protected array $excludedPaths = [ - 'vendor', - 'tests', - ]; - - use ArchitectureAsserts; - public function testForgottenDebugFunctions(): void { + $root = \dirname(__DIR__, 2); $functions = ['dump', 'trap', 'tr', 'td', 'var_dump']; - $layer = $this->layer(); - - foreach ($layer as $object) { - foreach ($object->uses as $use) { - foreach ($functions as $function) { - $function === $use and throw new \Exception( - \sprintf( - 'Function `%s()` is used in %s.', - $function, - $object->name, - ), - ); - } + + foreach ($this->phpFiles($root) as $file) { + $match = $this->findForbiddenFunctionCall(\file_get_contents($file), $functions); + if ($match === null) { + continue; + } + + [$function, $line] = $match; + + self::fail( + \sprintf( + 'Function `%s()` is used in %s:%d.', + $function, + \str_replace($root . DIRECTORY_SEPARATOR, '', $file), + $line, + ), + ); + } + + self::assertTrue(true); + } + + /** + * @return iterable + */ + private function phpFiles(string $root): iterable + { + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($root, \FilesystemIterator::SKIP_DOTS), + ); + + foreach ($iterator as $file) { + $path = $file->getPathname(); + if ( + !$file->isFile() + || $file->getExtension() !== 'php' + || \str_contains($path, DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR) + || \str_contains($path, DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) + ) { + continue; } + + yield $path; + } + } + + /** + * @param list $functions + * @return array{string, int}|null + */ + private function findForbiddenFunctionCall(string $code, array $functions): ?array + { + $tokens = \token_get_all($code); + + foreach ($tokens as $index => $token) { + if (!\is_array($token)) { + continue; + } + + if (!$this->isForbiddenFunctionToken($token, $functions)) { + continue; + } + + $next = $this->nextSignificantToken($tokens, $index + 1); + $previous = $this->previousSignificantToken($tokens, $index - 1); + + if ( + $next !== '(' + || $previous === '->' + || $previous === '::' + || (\is_array($previous) && $previous[0] === T_FUNCTION) + ) { + continue; + } + + return [$this->tokenFunctionName($token), $token[2]]; + } + + return null; + } + + /** + * @param array{0:int,1:string,2:int} $token + * @param list $functions + */ + private function isForbiddenFunctionToken(array $token, array $functions): bool + { + return \in_array($token[0], [T_STRING, T_NAME_FULLY_QUALIFIED, T_NAME_QUALIFIED], true) + && \in_array($this->tokenFunctionName($token), $functions, true); + } + + /** + * @param array{0:int,1:string,2:int} $token + */ + private function tokenFunctionName(array $token): string + { + return \ltrim(\substr(strrchr('\\' . $token[1], '\\') ?: $token[1], 1), '\\'); + } + + /** + * @param list $tokens + */ + private function nextSignificantToken(array $tokens, int $index): mixed + { + for ($count = \count($tokens); $index < $count; $index++) { + $token = $tokens[$index]; + if (\is_array($token) && $token[0] === T_WHITESPACE) { + continue; + } + + return $token; + } + + return null; + } + + /** + * @param list $tokens + */ + private function previousSignificantToken(array $tokens, int $index): mixed + { + for (; $index >= 0; $index--) { + $token = $tokens[$index]; + if (\is_array($token) && $token[0] === T_WHITESPACE) { + continue; + } + + return $token; } - $this->assertTrue(true); + return null; } } diff --git a/tests/Fixtures/src/Workflow/AbandonedChildWithTimerWorkflow.php b/tests/Fixtures/src/Workflow/AbandonedChildWithTimerWorkflow.php index 857a03cdd..dedfda3ae 100644 --- a/tests/Fixtures/src/Workflow/AbandonedChildWithTimerWorkflow.php +++ b/tests/Fixtures/src/Workflow/AbandonedChildWithTimerWorkflow.php @@ -17,7 +17,7 @@ class AbandonedChildWithTimerWorkflow #[WorkflowMethod('abandoned_workflow')] public function wait(int $timeoutInSeconds) { - Workflow::timer($timeoutInSeconds); + yield Workflow::timer($timeoutInSeconds); return 'Hello from child'; } } diff --git a/tests/Functional/Client/AbstractClient.php b/tests/Functional/Client/AbstractClient.php index 6734159bd..7857ed85b 100644 --- a/tests/Functional/Client/AbstractClient.php +++ b/tests/Functional/Client/AbstractClient.php @@ -28,10 +28,10 @@ abstract class AbstractClient extends AbstractFunctional * @param string $connection * @return WorkflowClient */ - protected function createClient(string $connection = '127.0.0.1:7233'): WorkflowClient + protected function createClient(?string $connection = null): WorkflowClient { return new WorkflowClient( - ServiceClient::create($connection) + ServiceClient::create($connection ?? (\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233')) ); } diff --git a/tests/Functional/Client/ActivityCompletionClientTestCase.php b/tests/Functional/Client/ActivityCompletionClientTestCase.php index 122cbb8b4..c918a1316 100644 --- a/tests/Functional/Client/ActivityCompletionClientTestCase.php +++ b/tests/Functional/Client/ActivityCompletionClientTestCase.php @@ -34,8 +34,7 @@ public function testCompleteAsyncActivityById() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(2); - $this->assertFileExists('runtime/activityId'); + $this->waitForExternalActivityFiles(); $data = json_decode(file_get_contents('runtime/activityId')); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -56,8 +55,7 @@ public function testCompleteAsyncActivityByIdExplicit() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/activityId'); + $this->waitForExternalActivityFiles(); $data = json_decode(file_get_contents('runtime/activityId')); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -78,8 +76,7 @@ public function testCompleteAsyncActivityByIdInvalid() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/activityId'); + $this->waitForExternalActivityFiles(); $data = json_decode(file_get_contents('runtime/activityId')); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -104,8 +101,7 @@ public function testCompleteAsyncActivityByToken() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/taskToken'); + $this->waitForExternalActivityFiles(); $taskToken = file_get_contents('runtime/taskToken'); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -126,8 +122,7 @@ public function testCompleteAsyncActivityByTokenInvalid() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/taskToken'); + $this->waitForExternalActivityFiles(); $taskToken = file_get_contents('runtime/taskToken'); unlink('runtime/taskToken'); @@ -153,8 +148,7 @@ public function testCompleteAsyncActivityByTokenExceptionally() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/taskToken'); + $this->waitForExternalActivityFiles(); $taskToken = file_get_contents('runtime/taskToken'); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -184,8 +178,7 @@ public function testCompleteAsyncActivityByTokenExceptionallyById() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(2); - $this->assertFileExists('runtime/taskToken'); + $this->waitForExternalActivityFiles(); $data = json_decode(file_get_contents('runtime/activityId')); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -221,8 +214,7 @@ public function testHeartBeatByID() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/taskToken'); + $this->waitForExternalActivityFiles(); $data = json_decode(file_get_contents('runtime/activityId')); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -268,8 +260,7 @@ public function testHeartBeatByToken() $this->assertNotEmpty($e->getExecution()->getID()); $this->assertNotEmpty($e->getExecution()->getRunID()); - sleep(1); - $this->assertFileExists('runtime/taskToken'); + $this->waitForExternalActivityFiles(); $taskToken = file_get_contents('runtime/taskToken'); unlink('runtime/taskToken'); unlink('runtime/activityId'); @@ -314,4 +305,20 @@ public function testHeartBeatByToken() // $this->assertInstanceOf(CanceledFailure::class, $e->getPrevious()); // } // } + + private function waitForExternalActivityFiles(int $timeoutSeconds = 10): void + { + $deadline = \microtime(true) + $timeoutSeconds; + + while (\microtime(true) < $deadline) { + if (\is_file('runtime/taskToken') && \is_file('runtime/activityId')) { + return; + } + + \usleep(100_000); + } + + $this->assertFileExists('runtime/taskToken'); + $this->assertFileExists('runtime/activityId'); + } } diff --git a/tests/Functional/DataConverterTestCase.php b/tests/Functional/DataConverterTestCase.php index b4e53529c..b9ba3f332 100644 --- a/tests/Functional/DataConverterTestCase.php +++ b/tests/Functional/DataConverterTestCase.php @@ -16,7 +16,7 @@ final class DataConverterTestCase extends TestCase protected function setUp(): void { $this->workflowClient = new WorkflowClient( - ServiceClient::create('127.0.0.1:7233') + ServiceClient::create(\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233') ); parent::setUp(); diff --git a/tests/Functional/HistoryLengthWorkflowTestCase.php b/tests/Functional/HistoryLengthWorkflowTestCase.php index 153aa426c..c87657a75 100644 --- a/tests/Functional/HistoryLengthWorkflowTestCase.php +++ b/tests/Functional/HistoryLengthWorkflowTestCase.php @@ -18,7 +18,7 @@ final class HistoryLengthWorkflowTestCase extends TestCase protected function setUp(): void { $this->workflowClient = new WorkflowClient( - ServiceClient::create('127.0.0.1:7233') + ServiceClient::create(\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233') ); $this->activityMocks = new ActivityMocker(); diff --git a/tests/Functional/Interceptor/AbstractClient.php b/tests/Functional/Interceptor/AbstractClient.php index 042a9eae7..03c61ff0c 100644 --- a/tests/Functional/Interceptor/AbstractClient.php +++ b/tests/Functional/Interceptor/AbstractClient.php @@ -26,10 +26,10 @@ abstract class AbstractClient extends AbstractFunctional * @param string $connection * @return WorkflowClient */ - protected function createClient(string $connection = '127.0.0.1:7233'): WorkflowClient + protected function createClient(?string $connection = null): WorkflowClient { return new WorkflowClient( - ServiceClient::create($connection), + ServiceClient::create($connection ?? (\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233')), interceptorProvider: new PipelineProvider([InterceptorCallsCounter::class]), ); } diff --git a/tests/Functional/NamedArgumentsTestCase.php b/tests/Functional/NamedArgumentsTestCase.php index 0a5e40251..ead2c7233 100644 --- a/tests/Functional/NamedArgumentsTestCase.php +++ b/tests/Functional/NamedArgumentsTestCase.php @@ -23,7 +23,7 @@ final class NamedArgumentsTestCase extends TestCase protected function setUp(): void { $this->workflowClient = new WorkflowClient( - ServiceClient::create('127.0.0.1:7233') + ServiceClient::create(\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233') ); parent::setUp(); diff --git a/tests/Functional/ReplayerTestCase.php b/tests/Functional/ReplayerTestCase.php index cf3eec6fe..fbc399ef8 100644 --- a/tests/Functional/ReplayerTestCase.php +++ b/tests/Functional/ReplayerTestCase.php @@ -27,7 +27,7 @@ final class ReplayerTestCase extends TestCase protected function setUp(): void { $this->workflowClient = new WorkflowClient( - ServiceClient::create('127.0.0.1:7233') + ServiceClient::create(\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233') ); parent::setUp(); diff --git a/tests/Functional/SimpleWorkflowTestCase.php b/tests/Functional/SimpleWorkflowTestCase.php index dfbeec033..43b862985 100644 --- a/tests/Functional/SimpleWorkflowTestCase.php +++ b/tests/Functional/SimpleWorkflowTestCase.php @@ -130,7 +130,7 @@ public function testWorkflowMethodInAbstractParent(): void protected function setUp(): void { $this->workflowClient = new WorkflowClient( - ServiceClient::create('127.0.0.1:7233'), + ServiceClient::create(\getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233'), ); $this->activityMocks = new ActivityMocker(); diff --git a/tests/Functional/bootstrap.php b/tests/Functional/bootstrap.php index e52282867..35ea6a24b 100644 --- a/tests/Functional/bootstrap.php +++ b/tests/Functional/bootstrap.php @@ -12,8 +12,9 @@ $systemInfo = \Temporal\Testing\SystemInfo::detect(); $environment = Environment::create(); -$environment->startTemporalTestServer(); +$environment->startTemporalServer(); (new SearchAttributeTestInvoker())(); +$command = $environment->command; $environment->startRoadRunner( rrCommand: [ $systemInfo->rrExecutable, @@ -21,11 +22,15 @@ '-c', '.rr.silent.yaml', '-w', 'tests/Functional', '-o', + 'temporal.namespace=' . $command->namespace, + '-o', + 'temporal.address=' . $command->address, + '-o', 'server.command=' . \implode(',', [ PHP_BINARY, - ...$environment->command->getPhpBinaryArguments(), + ...$command->getPhpBinaryArguments(), 'worker.php', - ...$environment->command->getCommandLineArguments(), + ...$command->getCommandLineArguments(), ]), ], configFile: 'tests/Functional/.rr.silent.yaml', diff --git a/tests/SearchAttributeTestInvoker.php b/tests/SearchAttributeTestInvoker.php index 621398704..9ff605826 100644 --- a/tests/SearchAttributeTestInvoker.php +++ b/tests/SearchAttributeTestInvoker.php @@ -4,29 +4,35 @@ namespace Temporal\Tests; -use Temporal\Api\Operatorservice\V1\OperatorServiceClient; -use Grpc\ChannelCredentials; use Temporal\Api\Operatorservice\V1\AddSearchAttributesRequest; +use Temporal\Client\GRPC\StatusCode; +use Temporal\Client\GRPC\OperatorClient; +use Temporal\Exception\Client\ServiceClientException; final class SearchAttributeTestInvoker { public function __invoke(): void { - $operation = new OperatorServiceClient( - getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233', - ['credentials' => ChannelCredentials::createInsecure()] - ); - $result = $operation->AddSearchAttributes( - new AddSearchAttributesRequest( - [ - 'search_attributes' => [ - 'attr1' => 2, // Keyword - 'attr2' => 5, // Bool - ] - ] - ) - ); + $namespace = getenv('TEMPORAL_NAMESPACE') ?: 'default'; - $result->getMetadata(); + try { + OperatorClient::create(getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233')->AddSearchAttributes( + new AddSearchAttributesRequest( + [ + 'search_attributes' => [ + 'attr1' => 2, // Keyword + 'attr2' => 5, // Bool + ], + 'namespace' => $namespace, + ], + ), + ); + } catch (ServiceClientException $e) { + if ($e->getCode() !== StatusCode::ALREADY_EXISTS) { + throw $e; + } + + echo "Search attributes already registered, skipping.\n"; + } } } diff --git a/tests/Unit/Client/GRPC/OperatorClientTestCase.php b/tests/Unit/Client/GRPC/OperatorClientTestCase.php new file mode 100644 index 000000000..30c879af5 --- /dev/null +++ b/tests/Unit/Client/GRPC/OperatorClientTestCase.php @@ -0,0 +1,383 @@ + new class extends ApiOperatorServiceClient { + public function __construct() {} + + public function getConnectivityState($try_to_connect = false): int + { + return ConnectionState::Ready->value; + } + + public function close(): void {} + }))->withInterceptorPipeline( + Pipeline::prepare([new class($captured) implements GrpcClientInterceptor { + public function __construct( + private readonly object $captured, + ) {} + + public function interceptCall( + string $method, + object $arg, + ContextInterface $ctx, + callable $next, + ): object { + $this->captured->method = $method; + $this->captured->request = $arg; + $this->captured->context = $ctx; + + return (new DeleteNamespaceResponse())->setDeletedNamespace('temporal-system-deleted'); + } + }]), + )->withAuthKey('test-key'); + + $response = $client->DeleteNamespace((new DeleteNamespaceRequest())->setNamespace('test-namespace')); + + self::assertSame('DeleteNamespace', $captured->method); + self::assertSame('test-namespace', $captured->request?->getNamespace()); + self::assertSame(['Bearer test-key'], $captured->context?->getMetadata()['Authorization'] ?? null); + self::assertSame('temporal-system-deleted', $response->getDeletedNamespace()); + } + + #[Test] + public function addSearchAttributes(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new AddSearchAttributesResponse(), + ); + + $client->AddSearchAttributes(new AddSearchAttributesRequest()); + + self::assertSame('AddSearchAttributes', $captured->method); + self::assertInstanceOf(AddSearchAttributesRequest::class, $captured->arg); + } + + #[Test] + public function removeSearchAttributes(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new RemoveSearchAttributesResponse(), + ); + + $client->RemoveSearchAttributes(new RemoveSearchAttributesRequest()); + + self::assertSame('RemoveSearchAttributes', $captured->method); + self::assertInstanceOf(RemoveSearchAttributesRequest::class, $captured->arg); + } + + #[Test] + public function listSearchAttributes(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new ListSearchAttributesResponse(), + ); + + $client->ListSearchAttributes(new ListSearchAttributesRequest()); + + self::assertSame('ListSearchAttributes', $captured->method); + self::assertInstanceOf(ListSearchAttributesRequest::class, $captured->arg); + } + + #[Test] + public function addOrUpdateRemoteCluster(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new AddOrUpdateRemoteClusterResponse(), + ); + + $client->AddOrUpdateRemoteCluster(new AddOrUpdateRemoteClusterRequest()); + + self::assertSame('AddOrUpdateRemoteCluster', $captured->method); + self::assertInstanceOf(AddOrUpdateRemoteClusterRequest::class, $captured->arg); + } + + #[Test] + public function removeRemoteCluster(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new RemoveRemoteClusterResponse(), + ); + + $client->RemoveRemoteCluster(new RemoveRemoteClusterRequest()); + + self::assertSame('RemoveRemoteCluster', $captured->method); + self::assertInstanceOf(RemoveRemoteClusterRequest::class, $captured->arg); + } + + #[Test] + public function listClusters(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + $client->ListClusters(new ListClustersRequest()); + + self::assertSame('ListClusters', $captured->method); + self::assertInstanceOf(ListClustersRequest::class, $captured->arg); + } + + #[Test] + public function getNexusEndpoint(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new GetNexusEndpointResponse(), + ); + + $client->GetNexusEndpoint(new GetNexusEndpointRequest()); + + self::assertSame('GetNexusEndpoint', $captured->method); + self::assertInstanceOf(GetNexusEndpointRequest::class, $captured->arg); + } + + #[Test] + public function createNexusEndpoint(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new CreateNexusEndpointResponse(), + ); + + $client->CreateNexusEndpoint(new CreateNexusEndpointRequest()); + + self::assertSame('CreateNexusEndpoint', $captured->method); + self::assertInstanceOf(CreateNexusEndpointRequest::class, $captured->arg); + } + + #[Test] + public function updateNexusEndpoint(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new UpdateNexusEndpointResponse(), + ); + + $client->UpdateNexusEndpoint(new UpdateNexusEndpointRequest()); + + self::assertSame('UpdateNexusEndpoint', $captured->method); + self::assertInstanceOf(UpdateNexusEndpointRequest::class, $captured->arg); + } + + #[Test] + public function deleteNexusEndpoint(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new DeleteNexusEndpointResponse(), + ); + + $client->DeleteNexusEndpoint(new DeleteNexusEndpointRequest()); + + self::assertSame('DeleteNexusEndpoint', $captured->method); + self::assertInstanceOf(DeleteNexusEndpointRequest::class, $captured->arg); + } + + #[Test] + public function listNexusEndpoints(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new ListNexusEndpointsResponse(), + ); + + $client->ListNexusEndpoints(new ListNexusEndpointsRequest()); + + self::assertSame('ListNexusEndpoints', $captured->method); + self::assertInstanceOf(ListNexusEndpointsRequest::class, $captured->arg); + } + + #[Test] + public function customContextIsPassedToInterceptor(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + $ctx = $client->getContext()->withMetadata(['x-custom' => ['value']]); + $client->ListClusters(new ListClustersRequest(), $ctx); + + self::assertSame(['value'], $captured->ctx->getMetadata()['x-custom'] ?? null); + } + + #[Test] + public function authKeyIsInjectedIntoContext(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + $client = $client->withAuthKey('operator-key'); + $client->ListClusters(new ListClustersRequest()); + + self::assertSame(['Bearer operator-key'], $captured->ctx->getMetadata()['Authorization'] ?? null); + } + + #[Test] + public function withoutAuthKeyNoAuthorizationHeader(): void + { + [$captured, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + $client->ListClusters(new ListClustersRequest()); + + self::assertArrayNotHasKey('Authorization', $captured->ctx->getMetadata()); + } + + #[Test] + public function withContextReturnsNewImmutableInstance(): void + { + [, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + $ctx = $client->getContext()->withMetadata(['foo' => ['bar']]); + $client2 = $client->withContext($ctx); + + self::assertNotSame($client, $client2); + self::assertSame($ctx, $client2->getContext()); + self::assertNotSame($ctx, $client->getContext()); + } + + #[Test] + public function withAuthKeyReturnsNewImmutableInstance(): void + { + [, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + $client2 = $client->withAuthKey('key'); + + self::assertNotSame($client, $client2); + } + + #[Test] + public function closeDisconnectsConnection(): void + { + $client = (new OperatorClient(static fn() => new class extends ApiOperatorServiceClient { + public function __construct() {} + + public function getConnectivityState($try_to_connect = false): int + { + return ConnectionState::TransientFailure->value; + } + + public function close(): void {} + })); + + $client->close(); + + self::assertFalse($client->getConnection()->isConnected()); + } + + #[Test] + public function implementsGrpcClientInterface(): void + { + [, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + self::assertInstanceOf(GrpcClientInterface::class, $client); + } + + #[Test] + public function implementsOperatorClientInterface(): void + { + [, $client] = $this->createInterceptedClient( + static fn() => new ListClustersResponse(), + ); + + self::assertInstanceOf(OperatorClientInterface::class, $client); + } + + /** + * @return array{object, OperatorClient} + */ + private function createInterceptedClient(\Closure $responseFactory): array + { + $captured = new class { + public ?string $method = null; + public ?object $arg = null; + public ?ContextInterface $ctx = null; + }; + + $client = (new OperatorClient(static fn() => new class extends ApiOperatorServiceClient { + public function __construct() {} + + public function getConnectivityState($try_to_connect = false): int + { + return ConnectionState::Ready->value; + } + + public function close(): void {} + }))->withInterceptorPipeline( + Pipeline::prepare([new class($captured, $responseFactory) implements GrpcClientInterceptor { + public function __construct( + private readonly object $captured, + private readonly \Closure $responseFactory, + ) {} + + public function interceptCall( + string $method, + object $arg, + ContextInterface $ctx, + callable $next, + ): object { + $this->captured->method = $method; + $this->captured->arg = $arg; + $this->captured->ctx = $ctx; + + return ($this->responseFactory)(); + } + }]), + ); + + return [$captured, $client]; + } +} diff --git a/tests/Unit/Internal/Activity/ActivityContextTestCase.php b/tests/Unit/Internal/Activity/ActivityContextTestCase.php new file mode 100644 index 000000000..ab9facd35 --- /dev/null +++ b/tests/Unit/Internal/Activity/ActivityContextTestCase.php @@ -0,0 +1,237 @@ +createContext(['activity_paused' => true]); + + try { + $context->heartbeat('test'); + self::fail('Activity pause was not propagated from the heartbeat response'); + } catch (ActivityPausedException $e) { + self::assertSame('activity-id', $e->getActivityId()); + } + + self::assertFalse($context->getCancellationDetails()?->cancelRequested ?? true); + self::assertTrue($context->getCancellationDetails()?->paused ?? false); + } + + #[Test] + public function heartbeatRecognizesApiNativeCancelField(): void + { + $context = $this->createContext(['cancel_requested' => true]); + + try { + $context->heartbeat('test'); + self::fail('Activity cancellation was not propagated from the heartbeat response'); + } catch (ActivityCanceledException $e) { + self::assertSame('activity-id', $e->getActivityId()); + } + + self::assertTrue($context->getCancellationDetails()?->cancelRequested ?? false); + self::assertFalse($context->getCancellationDetails()?->paused ?? true); + } + + #[Test] + public function heartbeatHappyPathDoesNotThrow(): void + { + $context = $this->createContext([]); + + $context->heartbeat('test'); + + self::assertNull($context->getCancellationDetails()); + } + + #[Test] + public function heartbeatRecognizesLegacyCanceledFlag(): void + { + $context = $this->createContext(['canceled' => true]); + + $this->expectException(ActivityCanceledException::class); + $context->heartbeat('test'); + } + + #[Test] + public function heartbeatRecognizesCamelCaseCancelRequestedFlag(): void + { + $context = $this->createContext(['cancelRequested' => true]); + + $this->expectException(ActivityCanceledException::class); + $context->heartbeat('test'); + } + + #[Test] + public function heartbeatRecognizesLegacyPausedFlag(): void + { + $context = $this->createContext(['paused' => true]); + + $this->expectException(ActivityPausedException::class); + $context->heartbeat('test'); + } + + #[Test] + public function heartbeatRecognizesCamelCaseActivityPausedFlag(): void + { + $context = $this->createContext(['activityPaused' => true]); + + $this->expectException(ActivityPausedException::class); + $context->heartbeat('test'); + } + + #[Test] + public function heartbeatWithBothCancelAndPauseThrowsCanceled(): void + { + // When both flags are set, cancel takes precedence + $context = $this->createContext(['cancel_requested' => true, 'activity_paused' => true]); + + try { + $context->heartbeat('test'); + self::fail('Expected exception'); + } catch (ActivityCanceledException) { + // Cancel takes precedence + } + + $details = $context->getCancellationDetails(); + self::assertNotNull($details); + self::assertTrue($details->cancelRequested); + self::assertTrue($details->paused); + } + + #[Test] + public function heartbeatServiceClientExceptionWrappedInActivityCompletionException(): void + { + $rpc = $this->createMock(RPCConnectionInterface::class); + $rpc->expects(self::once()) + ->method('call') + ->willThrowException( + new ServiceClientException((object) ['code' => 13, 'metadata' => []]), + ); + + $context = new ActivityContext( + $rpc, + DataConverter::createDefault(), + EncodedValues::empty(), + Header::empty(), + ); + + $info = $context->getInfo(); + $info->workflowExecution = new WorkflowExecution('workflow-id', 'run-id'); + $info->id = 'activity-id'; + $info->type->name = 'activity-type'; + + try { + $context->heartbeat('test'); + self::fail('Expected ActivityCompletionException'); + } catch (ActivityCompletionException $e) { + self::assertSame('activity-id', $e->getActivityId()); + self::assertInstanceOf(ServiceClientException::class, $e->getPrevious()); + } + } + + #[Test] + public function heartbeatFalseResponseFlagsDoNotTriggerException(): void + { + $context = $this->createContext(['cancel_requested' => false, 'activity_paused' => false]); + + $context->heartbeat('test'); + + self::assertNull($context->getCancellationDetails()); + } + + #[Test] + public function heartbeatNonArrayResponseDoesNotThrow(): void + { + $rpc = $this->createMock(RPCConnectionInterface::class); + $rpc->expects(self::once()) + ->method('call') + ->willReturn('ok'); + + $context = new ActivityContext( + $rpc, + DataConverter::createDefault(), + EncodedValues::empty(), + Header::empty(), + ); + + $info = $context->getInfo(); + $info->workflowExecution = new WorkflowExecution('workflow-id', 'run-id'); + $info->id = 'activity-id'; + $info->type->name = 'activity-type'; + + $context->heartbeat('test'); + + self::assertNull($context->getCancellationDetails()); + } + + #[Test] + public function heartbeatObjectResponseIsConvertedToArray(): void + { + $rpc = $this->createMock(RPCConnectionInterface::class); + $rpc->expects(self::once()) + ->method('call') + ->willReturn((object) ['cancel_requested' => true]); + + $context = new ActivityContext( + $rpc, + DataConverter::createDefault(), + EncodedValues::empty(), + Header::empty(), + ); + + $info = $context->getInfo(); + $info->workflowExecution = new WorkflowExecution('workflow-id', 'run-id'); + $info->id = 'activity-id'; + $info->type->name = 'activity-type'; + + $this->expectException(ActivityCanceledException::class); + $context->heartbeat('test'); + } + + /** + * @param array $response + */ + private function createContext(array $response): ActivityContext + { + $rpc = $this->createMock(RPCConnectionInterface::class); + $rpc->expects(self::once()) + ->method('call') + ->with( + 'temporal.RecordActivityHeartbeat', + self::callback(static fn(array $payload): bool => isset($payload['taskToken'], $payload['details'])), + ) + ->willReturn($response); + + $context = new ActivityContext( + $rpc, + DataConverter::createDefault(), + EncodedValues::empty(), + Header::empty(), + ); + + $info = $context->getInfo(); + $info->workflowExecution = new WorkflowExecution('workflow-id', 'run-id'); + $info->id = 'activity-id'; + $info->type->name = 'activity-type'; + + return $context; + } +}