Skip to content

Add MethodExtension to ServiceImplInstance#46

Open
Quinn-With-Two-Ns wants to merge 1 commit into
nexus-rpc:mainfrom
Quinn-With-Two-Ns:NEXUS-415
Open

Add MethodExtension to ServiceImplInstance#46
Quinn-With-Two-Ns wants to merge 1 commit into
nexus-rpc:mainfrom
Quinn-With-Two-Ns:NEXUS-415

Conversation

@Quinn-With-Two-Ns

Copy link
Copy Markdown
Contributor

Add MethodExtension to ServiceImplInstance. This allows users, like the Temporal SDK, to define custom annotations on service handlers.

This will allow us to define Nexus Service like so.

  @ServiceImpl(service = SugarService.class)
  public static class SugarServiceImpl {
    @TemporalOperation
    public TemporalOperationResult<String> start(
        TemporalOperationStartContext ctx, TemporalNexusClient client, String input) {
      return client.startWorkflow(
          SugarTargetWorkflow.class,
          SugarTargetWorkflow::run,
          input,
          WorkflowOptions.newBuilder().setWorkflowId("sugar-" + ctx.getRequestId()).build());
    }
  }

See also temporalio/sdk-java#2928

* <p>Extensions are responsible for their own validation of method shape (parameter types, return
* type, modifiers) and for translating the method into an {@link OperationHandler}.
*/
public interface MethodExtension {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's mark this as experimental. We should do this for all of the non final APIs like the ServiceImpl.

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.

2 participants