Skip to content
New issue

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

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

Already on GitHub? # to your account

Add support for upsert memo #2202

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

Add support for upsert memo to the Java SDK and test server.

closes #623

@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner August 30, 2024 19:32
@@ -156,6 +156,11 @@ public void upsertTypedSearchAttributes(SearchAttributeUpdate<?>... searchAttrib
next.upsertTypedSearchAttributes(searchAttributeUpdates);
}

@Override
public void upsertMemo(Map<String, Object> memo) {
next.upsertSearchAttributes(memo);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
next.upsertSearchAttributes(memo);
next.upsertMemo(memo);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests passed so looks like we must be missing some test coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep added some test coverage for this, will need to think long term if there is some way I can test all the interceptors programatically

@@ -1186,6 +1186,16 @@ public static void upsertTypedSearchAttributes(
WorkflowInternal.upsertTypedSearchAttributes(searchAttributeUpdates);
}

/**
* Updates a Workflow Memos by applying {@code memoUpdates} to the existing Memos set attached to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify how a memo value is removed? Is this done by setting a null object? So can memo contain a null value for a key? In .NET we accept memo update objects to remove any ambiguity. I forget what Go does here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes by setting a null value same as Go.

Copy link
Member

@cretz cretz Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between a null value with key present and an absent key? Specifically, if I do something like upsertMemo(Collections.singletonMap("key-that-exists-from-start", null)), what will the raw memo be if I do describe workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key-that-exists-from-start would be removed by the server just like Go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 May be worth mentioning in docs that that is how to remove a key

@@ -156,6 +156,11 @@ public void upsertTypedSearchAttributes(SearchAttributeUpdate<?>... searchAttrib
next.upsertTypedSearchAttributes(searchAttributeUpdates);
}

@Override
public void upsertMemo(Map<String, Object> memo) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Java offer the ability for me to see the whole memo collection inside the workflow? For instance if I wanted to know all memo keys in a workflow, can I? Do we need to add that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No and No, at least no one has asked for it and I see no reason this PR would need to add it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. My concern is if/when we do we need to make sure to more explicitly make sure null means remove from a Map POV.

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit add6c4e into temporalio:master Sep 5, 2024
8 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upsert memo support
3 participants