restatedev / restatedev/sdk-java

support annotation-based approach

Open
#541 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
60
Forks
17
PR merge metrics
No merged PRs in 30d

Description

I don't like passing all the app logic as lambdas because it makes the codebase messy. It would be great if Restate used an annotation-based approach instead (or something else), which would mean moving the responsibility from the caller method to the called method

What if we created a @Run annotation instead of calling ctx.run()? For example:

  @Workflow
  public boolean run(WorkflowContext ctx, Email email) {
    String secret = ctx.random().nextUUID().toString();
    ctx.set(STATUS, "Generated secret");

    // ctx.run("send email", () -> sendEmailWithLink(email, secret));
    sendEmailWithLink(email, secret);
    ctx.set(STATUS, "Sent email");

    String clickSecret =
        ctx.promise(EMAIL_CLICKED)
            .future()
            .await();
    ctx.set(STATUS, "Clicked email");

    return clickSecret.equals(secret);
  }

  @Run("send email")
  public void sendEmailWithLink(Email email, String secret) {
       // ......
   }

That's not only for ctx.run(), it can be applied to a lot of methods.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the current ctx.run() usage and the @Workflow example in the issue, then compare how moving responsibility to a called method would affect other context methods. Define the annotation semantics, supported method boundaries, and compatibility expectations before implementation; done means the approach is specified and its feasibility is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.