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 test environment support for Nexus Operations #1475

Merged

Conversation

bergundy
Copy link
Member

Test environment now supports Nexus Operations.
I've added a partial Client implementation for the test env to support what I predict will be the most frequently used methods.
Specifically WorkflowRunOperation and SyncOperation can use the client to signal and query workflows.

Users can register arbitrary Nexus Operation handlers if they want to mock the operation completely.

This PR is stacked on top of the other two Nexus PRs and completes the basic functionality.

@bergundy bergundy requested a review from a team as a code owner May 16, 2024 23:52
@bergundy bergundy force-pushed the bergundy/nexus-operation-from-workflow branch from 7b5d3b9 to dcfa8cf Compare May 17, 2024 00:31
@bergundy bergundy force-pushed the bergundy/nexus-in-test-env branch from 6cadae7 to 69b8101 Compare May 17, 2024 00:32
type isWorkflowRunOpContextKeyType struct{}

// IsWorkflowRunOpContextKey is a key to mark that the current context is used within a workflow run operation.
// The fake test env client verifies this key is set on the context to decide whether it should execute a method or
Copy link
Member

Choose a reason for hiding this comment

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

Why not just not have a fake test env client and instead have an always-fail one? Can you just intercept and do the test-env stuff earlier in the Nexus call instead of keeping this half-implemented fake client around that now is only used sometimes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not without adding more hacks to WorkflowRunOperation or exposing more information about a nexus.Service and doing ugly type casts on registration.

Copy link
Member

@cretz cretz May 28, 2024

Choose a reason for hiding this comment

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

May need that anyways for an OnNexusOperation mock

@Quinn-With-Two-Ns
Copy link
Contributor

Do we plan to add a TestNexusEnvironment as well to allow users to test their nexus operations outside of any workflow like an activity?

@bergundy
Copy link
Member Author

Do we plan to add a TestNexusEnvironment as well to allow users to test their nexus operations outside of any workflow like an activity?

Yes, and also OnNexusOperation, but I'll track those for public preview.
I want to push to get Nexus to production before investing further in the Go SDK.

@Quinn-With-Two-Ns
Copy link
Contributor

Yes, and also OnNexusOperation, but I'll track those for public preview.
I want to push to get Nexus to production before investing further in the Go SDK.

Yeah fine with my, I just wanted to make sure if not done in the PR they are tracked

@bergundy
Copy link
Member Author

Here's the issue FTR #1491

@bergundy bergundy merged commit 42984a0 into bergundy/nexus-operation-from-workflow Jun 19, 2024
4 of 12 checks passed
@bergundy bergundy deleted the bergundy/nexus-in-test-env branch June 19, 2024 23:36
bergundy added a commit that referenced this pull request Jun 19, 2024
* Execute nexus operation from a workflow

* Address review comments

* Add test environment support for Nexus Operations (#1475)

* Add test environment support for Nexus Operations

* Change client to not allow any direct calls
@bergundy bergundy mentioned this pull request Jun 19, 2024
2 tasks
@bergundy bergundy mentioned this pull request Jul 19, 2024
bergundy added a commit that referenced this pull request Jul 22, 2024
## What was changed

- Added the `temporalnexus` package and implemented the handler side for Nexus, including registering and dispatching Nexus Operations.
- Added the ability to execute Nexus Operations from a workflow.
- Added basic support for running Nexus Operations in the test environment.
- Added memoizing to `worker.Start()` to return consistent errors to callers and avoid rerunning the function unnecessarily.
- Updated the integration test's dev server to run CLI `0.14.0-nexus.0` which includes server `1.25.0-rc.0`.

See the [proposal](https://github.com/temporalio/proposals/blob/b72c49b0c2278e916265b00a49638006f8fce469/nexus/sdk-go.md) for more information.

Most of this code has been reviewed already in #1466, #1473, and #1475, which are all squashed in the first commit.
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