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

Add support for attaching to a running workflow #2424

Merged
merged 10 commits into from
Feb 24, 2025

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

Add support for attaching to a running workflow.

See similar Go PR: temporalio/sdk-go#1797

@Quinn-With-Two-Ns
Copy link
Contributor Author

Marking as draft while I add tests, will need #2415 merged and probably a server release to merge

}

public OnConflictOptions build() {
return new OnConflictOptions(attachRequestId, attachCompletionCallbacks, attachLinks);
Copy link
Member

Choose a reason for hiding this comment

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

The server doesn't allow attaching callbacks without also attaching a request ID (as of yesterday). I'm wondering if we should verify that SDK side and document it on the builder setters. We definitely should in the api (@rodrigozhou).

* already running, the options specifies the actions to be taken on the running workflow. If
* not set or use together with any other WorkflowIDConflictPolicy, this parameter is ignored.
*
* <p>WARNING: Not intended for User Code.
Copy link
Member

Choose a reason for hiding this comment

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

I wish there was a way to hide this. Maybe with a private subclass and cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't be private because it needs to be accessible by the Internal package. Passing them through a thread local is an option, but puts a requirement on the calling thread. I think we should revisit before we GA

Comment on lines +200 to +203
if (!async) {
startedCallback.apply(Optional.empty(), null);
}
Copy link
Member

Choose a reason for hiding this comment

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

I would just keep all of this logic in notifyStarted() but this is fine.

@Quinn-With-Two-Ns Quinn-With-Two-Ns marked this pull request as ready for review February 22, 2025 01:06
@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner February 22, 2025 01:06
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Nothing blocking

+ '}';
}

private OnConflictOptions(
Copy link
Member

Choose a reason for hiding this comment

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

Pedantic, but a bit strange to me to see a constructor below the instance methods

* io.temporal.api.enums.v1.WorkflowIdConflictPolicy#WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING}
*/
@Experimental
public class OnConflictOptions {
Copy link
Member

Choose a reason for hiding this comment

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

Hrmm, it was my understanding that we were going to hive this from users, though I know that is difficult in Java. If instead we're ok with showing to users but marking experimental, I think we should do the same in Go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't avoid exposing it given the structure of the Java SDK, just because the Java SDK has this unfortunate limitation doesn't mean other SDKs should copy it

Copy link
Member

@cretz cretz Feb 24, 2025

Choose a reason for hiding this comment

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

So the question becomes should other SDKs follow Go's lead or Java's lead here. Sounds like we are saying Java will be the outlier instead of updating Go to expose as well?

Copy link
Contributor Author

@Quinn-With-Two-Ns Quinn-With-Two-Ns Feb 24, 2025

Choose a reason for hiding this comment

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

Yes other SDKs should not copy it

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit d0cf3f3 into temporalio:master Feb 24, 2025
8 checks passed
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.

3 participants