Skip to content

Commit 0b021da

Browse files
committed
Add Workflow::upsertTypedSearchAttributes() helper
1 parent f5e6323 commit 0b021da

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/Internal/Transport/Request/UpsertTypedSearchAttributes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class UpsertTypedSearchAttributes extends Request
1313
public const NAME = 'UpsertWorkflowTypedSearchAttributes';
1414

1515
/**
16-
* @param list<SearchAttributeUpdate> $searchAttributes
16+
* @param array<array-key, SearchAttributeUpdate> $searchAttributes
1717
*/
1818
public function __construct(
1919
private readonly array $searchAttributes,
@@ -22,7 +22,7 @@ public function __construct(
2222
}
2323

2424
/**
25-
* @return list<SearchAttributeUpdate>
25+
* @return array<array-key, SearchAttributeUpdate>
2626
*/
2727
public function getSearchAttributes(): array
2828
{

src/Internal/Workflow/ScopeContext.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ public function upsertSearchAttributes(array $searchAttributes): void
113113

114114
public function upsertTypedSearchAttributes(SearchAttributeUpdate ...$updates): void
115115
{
116-
$this->request(
117-
new UpsertTypedSearchAttributes($updates),
118-
);
116+
$this->request(new UpsertTypedSearchAttributes($updates));
119117
}
120118

121119
#[\Override]

src/Workflow.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Temporal\Activity\ActivityOptions;
1717
use Temporal\Activity\ActivityOptionsInterface;
1818
use Temporal\Client\WorkflowStubInterface;
19+
use Temporal\Common\SearchAttributes\SearchAttributeUpdate;
1920
use Temporal\DataConverter\Type;
2021
use Temporal\DataConverter\ValuesInterface;
2122
use Temporal\Exception\OutOfContextException;
@@ -911,6 +912,21 @@ public static function upsertSearchAttributes(array $searchAttributes): void
911912
self::getCurrentContext()->upsertSearchAttributes($searchAttributes);
912913
}
913914

915+
/**
916+
* Upsert typed Search Attributes
917+
*
918+
* ```php
919+
* Workflow::upsertTypedSearchAttributes(
920+
* SearchAttributeKey::forKeyword('CustomKeyword')->valueSet('CustomValue'),
921+
* SearchAttributeKey::forInt('MyCounter')->valueSet(42),
922+
* );
923+
* ```
924+
*/
925+
public static function upsertTypedSearchAttributes(SearchAttributeUpdate ...$updates): void
926+
{
927+
self::getCurrentContext()->upsertTypedSearchAttributes(...$updates);
928+
}
929+
914930
/**
915931
* Generate a UUID.
916932
*

0 commit comments

Comments
 (0)