Skip to content

support annotation-based approach #541

@zakaria-shahen

Description

@zakaria-shahen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions