-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #411: Client improvements
- Loading branch information
Showing
39 changed files
with
1,097 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Client\Common; | ||
|
||
use Temporal\Common\RetryOptions; | ||
|
||
interface ClientContextInterface | ||
{ | ||
/** | ||
* All the service client calls will be made with the specified timeout. | ||
* | ||
* @param float $timeout in seconds | ||
*/ | ||
public function withTimeout(float $timeout): static; | ||
|
||
/** | ||
* Set the deadline for any service requests | ||
*/ | ||
public function withDeadline(\DateTimeInterface $deadline): static; | ||
|
||
public function withRetryOptions(RetryOptions $options): static; | ||
|
||
/** | ||
* A metadata map to send to the server | ||
* | ||
* @param array<string, array<string>> $metadata | ||
*/ | ||
public function withMetadata(array $metadata): static; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Client\Common; | ||
|
||
use Temporal\Client\GRPC\ServiceClientInterface; | ||
use Temporal\Common\RetryOptions; | ||
use Temporal\Internal\Support\DateInterval; | ||
|
||
/** | ||
* The trait provides methods to configure context in ServiceClientInterface. | ||
* | ||
* @internal | ||
*/ | ||
trait ClientContextTrait | ||
{ | ||
private ServiceClientInterface $client; | ||
|
||
/** | ||
* All the service client calls will be made with the specified timeout. | ||
* | ||
* @param float $timeout in seconds | ||
*/ | ||
public function withTimeout(float $timeout): static | ||
{ | ||
$new = clone $this; | ||
$context = $new->client->getContext(); | ||
// Convert to milliseconds | ||
/** @psalm-suppress InvalidOperand */ | ||
$timeout *= 1000; | ||
$new->client = $new->client->withContext( | ||
$context->withTimeout((int)$timeout, DateInterval::FORMAT_MILLISECONDS), | ||
); | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Set the deadline for any service requests | ||
*/ | ||
public function withDeadline(\DateTimeInterface $deadline): static | ||
{ | ||
$new = clone $this; | ||
$context = $new->client->getContext(); | ||
$new->client = $new->client->withContext($context->withDeadline($deadline)); | ||
return $new; | ||
} | ||
|
||
public function withRetryOptions(RetryOptions $options): static | ||
{ | ||
$new = clone $this; | ||
$context = $new->client->getContext(); | ||
$new->client = $new->client->withContext($context->withRetryOptions($options)); | ||
return $new; | ||
} | ||
|
||
/** | ||
* A metadata map to send to the server | ||
* | ||
* @param array<string, array<string>> $metadata | ||
*/ | ||
public function withMetadata(array $metadata): static | ||
{ | ||
$new = clone $this; | ||
$context = $new->client->getContext(); | ||
$new->client = $new->client->withContext($context->withMetadata($metadata)); | ||
return $new; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of Temporal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Client\Common; | ||
|
||
final class ServerCapabilities | ||
{ | ||
/** | ||
* @param bool $signalAndQueryHeader | ||
* True if signal and query headers are supported. | ||
* @param bool $internalErrorDifferentiation | ||
* True if internal errors are differentiated from other types of errors for purposes of | ||
* retrying non-internal errors. | ||
* When unset/false, clients retry all failures. When true, clients should only retry | ||
* non-internal errors. | ||
* @param bool $activityFailureIncludeHeartbeat | ||
* True if RespondActivityTaskFailed API supports including heartbeat details | ||
* @param bool $supportsSchedules | ||
* Supports scheduled workflow features. | ||
* @param bool $encodedFailureAttributes | ||
* True if server uses protos that include temporal.api.failure.v1.Failure.encoded_attributes | ||
* @param bool $buildIdBasedVersioning | ||
* True if server supports dispatching Workflow and Activity tasks based on a worker's build_id | ||
* (see: | ||
* https:/temporalio/proposals/blob/a123af3b559f43db16ea6dd31870bfb754c4dc5e/versioning/worker-versions.md) | ||
* @param bool $upsertMemo | ||
* True if server supports upserting workflow memo | ||
* @param bool $eagerWorkflowStart | ||
* True if server supports eager workflow task dispatching for the StartWorkflowExecution API | ||
* @param bool $sdkMetadata | ||
* True if the server knows about the sdk metadata field on WFT completions and will record | ||
* it in history | ||
* @param bool $countGroupByExecutionStatus | ||
* True if the server supports count group by execution status | ||
* (-- api-linter: core::0140::prepositions=disabled --) | ||
*/ | ||
public function __construct( | ||
public readonly bool $signalAndQueryHeader = false, | ||
public readonly bool $internalErrorDifferentiation = false, | ||
public readonly bool $activityFailureIncludeHeartbeat = false, | ||
public readonly bool $supportsSchedules = false, | ||
public readonly bool $encodedFailureAttributes = false, | ||
public readonly bool $buildIdBasedVersioning = false, | ||
public readonly bool $upsertMemo = false, | ||
public readonly bool $eagerWorkflowStart = false, | ||
public readonly bool $sdkMetadata = false, | ||
public readonly bool $countGroupByExecutionStatus = false, | ||
) { | ||
} | ||
|
||
/** | ||
* True if signal and query headers are supported. | ||
* | ||
* @deprecated Use {@see self::$signalAndQueryHeader} instead. | ||
*/ | ||
public function isSignalAndQueryHeaderSupports(): bool | ||
{ | ||
return $this->signalAndQueryHeader; | ||
} | ||
|
||
/** | ||
* True if internal errors are differentiated from other types of errors for purposes of | ||
* retrying non-internal errors. | ||
* When unset/false, clients retry all failures. When true, clients should only retry | ||
* non-internal errors. | ||
* | ||
* @deprecated Use {@see self::$internalErrorDifferentiation} instead. | ||
*/ | ||
public function isInternalErrorDifferentiation(): bool | ||
{ | ||
return $this->internalErrorDifferentiation; | ||
} | ||
} | ||
|
||
\class_alias(ServerCapabilities::class, 'Temporal\Client\ServerCapabilities'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of Temporal package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Client; | ||
|
||
final class CountWorkflowExecutions | ||
{ | ||
public function __construct( | ||
public readonly int $count, | ||
) { | ||
if (!\class_exists(\Temporal\Client\Workflow\CountWorkflowExecutions::class)) { | ||
/** | ||
* @deprecated use {@see \Temporal\Client\Workflow\CountWorkflowExecutions} instead. Will be removed in the future. | ||
*/ | ||
class CountWorkflowExecutions | ||
{ | ||
} | ||
} |
Oops, something went wrong.