File tree Expand file tree Collapse file tree 3 files changed +61
-2
lines changed
Expand file tree Collapse file tree 3 files changed +61
-2
lines changed Original file line number Diff line number Diff line change 1414abstract class SearchAttributeUpdate
1515{
1616 /**
17- * @param non-empty-string $key
17+ * @param non-empty-string $name
1818 */
1919 protected function __construct (
20- public readonly string $ key ,
20+ public readonly string $ name ,
2121 public readonly ValueType $ type ,
2222 ) {}
2323
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Temporal \Internal \Transport \Request ;
6+
7+ use Temporal \Common \SearchAttributes \SearchAttributeUpdate ;
8+ use Temporal \Common \SearchAttributes \SearchAttributeUpdate \ValueSet ;
9+ use Temporal \Worker \Transport \Command \Client \Request ;
10+
11+ class UpsertTypedSearchAttributes extends Request
12+ {
13+ public const NAME = 'UpsertWorkflowTypedSearchAttributes ' ;
14+
15+ /**
16+ * @param list<SearchAttributeUpdate> $searchAttributes
17+ */
18+ public function __construct (
19+ private readonly array $ searchAttributes ,
20+ ) {
21+ parent ::__construct (self ::NAME , ['searchAttributes ' => $ this ->prepareSearchAttributes ()]);
22+ }
23+
24+ /**
25+ * @return list<SearchAttributeUpdate>
26+ */
27+ public function getSearchAttributes (): array
28+ {
29+ return $ this ->searchAttributes ;
30+ }
31+
32+ private function prepareSearchAttributes (): array
33+ {
34+ $ result = [];
35+ foreach ($ this ->searchAttributes as $ attr ) {
36+ $ result [$ attr ->name ] = $ attr instanceof ValueSet
37+ ? [
38+ 'type ' => $ attr ->type ->value ,
39+ 'operation ' => 'set ' ,
40+ 'value ' => $ attr ->value ,
41+ ]
42+ : [
43+ 'type ' => $ attr ->type ->value ,
44+ 'operation ' => 'unset ' ,
45+ ];
46+ }
47+
48+ return $ result ;
49+ }
50+ }
Original file line number Diff line number Diff line change 1313
1414use React \Promise \Deferred ;
1515use React \Promise \PromiseInterface ;
16+ use Temporal \Common \SearchAttributes \SearchAttributeUpdate ;
1617use Temporal \Exception \Failure \CanceledFailure ;
1718use Temporal \Internal \Transport \CompletableResult ;
19+ use Temporal \Internal \Transport \Request \UpsertTypedSearchAttributes ;
1820use Temporal \Internal \Workflow \Process \Scope ;
1921use Temporal \Worker \Transport \Command \RequestInterface ;
2022use Temporal \Workflow \CancellationScopeInterface ;
@@ -109,6 +111,13 @@ public function upsertSearchAttributes(array $searchAttributes): void
109111 );
110112 }
111113
114+ public function upsertTypedSearchAttributes (SearchAttributeUpdate ...$ updates ): void
115+ {
116+ $ this ->request (
117+ new UpsertTypedSearchAttributes ($ updates ),
118+ );
119+ }
120+
112121 #[\Override]
113122 public function destroy (): void
114123 {
You can’t perform that action at this time.
0 commit comments