Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Typed Search Attributes #553

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Expose Typed Search Attributes #553

wants to merge 22 commits into from

Conversation

roxblnfk
Copy link
Collaborator

@roxblnfk roxblnfk commented Jan 16, 2025

What was changed

Exposed Typed Search Attributes:

  • Collection \Temporal\Common\TypedSearchAttributes
  • \Temporal\Common\SearchAttributes\SearchAttributeKey and typed values
  • New API:
    • Workflow::upsertTypedSearchAttributes()
    • WorkflowOptions::withTypedSearchAttributes()

Fixed:

  • \Temporal\Internal\Workflow\ScopeContext::upsertSearchAttributes() changes Search Attributes in the current Workflow state
  • Upsert SA request is not memorized now because there is no response from RoadRunner side

Based on https://github.com/temporalio/proposals/blob/904b7ed8266b5e6edc0cbf17abcf98fc8de25775/all-sdk/sdk-typed-search-attributes.md?plain=1

Checklist

  1. Closes [Feature Request] Typed Search Attributes #516
  2. How was this tested: added acceptance tests
  3. Any docs updates needed?

Examples

Client API

$stub = $client->newUntypedWorkflowStub(
    'Extra_Workflow_TypedSearchAttributes',
    WorkflowOptions::new()
        ->withTaskQueue($feature->taskQueue)
        ->withTypedSearchAttributes(
            TypedSearchAttributes::empty()
                ->withValue(SearchAttributeKey::forFloat('testFloat'), 1.1)
                ->withValue(SearchAttributeKey::forInteger('testInt'), -2)
                ->withValue(SearchAttributeKey::forBool('testBool'), false)
                ->withValue(SearchAttributeKey::forString('testString'), 'foo')
                ->withValue(SearchAttributeKey::forKeyword('testKeyword'), 'bar')
                ->withValue(SearchAttributeKey::forKeywordList('testKeywordList'), ['baz'])
                ->withValue(
                    SearchAttributeKey::forDatetime('testDatetime'),
                    new \DateTimeImmutable('2019-01-01T00:00:00Z'),
                )
        ),
);

Workflow context

// Get Typed SA collection
$collection = Workflow::getInfo()->typedSearchAttributes;

// Update SA
Workflow::upsertTypedSearchAttributes(
    SearchAttributeKey::forString('key-string')->valueSet('foo bar'),
    SearchAttributeKey::forBool('key-bool')->valueSet(true),
);

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
php ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 8:25am

@roxblnfk roxblnfk requested a review from wolfy-j January 20, 2025 09:10
@roxblnfk roxblnfk marked this pull request as ready for review January 20, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Typed Search Attributes
3 participants