Skip to content

Commit

Permalink
Add Workflow::upsertTypedSearchAttributes() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Dec 30, 2024
1 parent f5e6323 commit 0b021da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UpsertTypedSearchAttributes extends Request
public const NAME = 'UpsertWorkflowTypedSearchAttributes';

/**
* @param list<SearchAttributeUpdate> $searchAttributes
* @param array<array-key, SearchAttributeUpdate> $searchAttributes
*/
public function __construct(
private readonly array $searchAttributes,
Expand All @@ -22,7 +22,7 @@ public function __construct(
}

/**
* @return list<SearchAttributeUpdate>
* @return array<array-key, SearchAttributeUpdate>
*/
public function getSearchAttributes(): array
{
Expand Down
4 changes: 1 addition & 3 deletions src/Internal/Workflow/ScopeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public function upsertSearchAttributes(array $searchAttributes): void

public function upsertTypedSearchAttributes(SearchAttributeUpdate ...$updates): void
{
$this->request(
new UpsertTypedSearchAttributes($updates),
);
$this->request(new UpsertTypedSearchAttributes($updates));
}

#[\Override]
Expand Down
16 changes: 16 additions & 0 deletions src/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Temporal\Activity\ActivityOptions;
use Temporal\Activity\ActivityOptionsInterface;
use Temporal\Client\WorkflowStubInterface;
use Temporal\Common\SearchAttributes\SearchAttributeUpdate;
use Temporal\DataConverter\Type;
use Temporal\DataConverter\ValuesInterface;
use Temporal\Exception\OutOfContextException;
Expand Down Expand Up @@ -911,6 +912,21 @@ public static function upsertSearchAttributes(array $searchAttributes): void
self::getCurrentContext()->upsertSearchAttributes($searchAttributes);
}

/**
* Upsert typed Search Attributes
*
* ```php
* Workflow::upsertTypedSearchAttributes(
* SearchAttributeKey::forKeyword('CustomKeyword')->valueSet('CustomValue'),
* SearchAttributeKey::forInt('MyCounter')->valueSet(42),
* );
* ```
*/
public static function upsertTypedSearchAttributes(SearchAttributeUpdate ...$updates): void
{
self::getCurrentContext()->upsertTypedSearchAttributes(...$updates);
}

/**
* Generate a UUID.
*
Expand Down

0 comments on commit 0b021da

Please sign in to comment.