Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go/basics/part3/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (SignupWorkflow) Run(ctx restate.WorkflowContext, user User) (bool, error)

// Wait until user clicked email verification link
// Promise gets resolved or rejected by the other handlers
clickSecret, err := restate.Promise[string](ctx, "email-link").Result()
clickSecret, err := restate.Promise[string](ctx, "link-clicked").Result()
if err != nil {
return false, err
}
Expand All @@ -61,7 +61,7 @@ func (SignupWorkflow) Run(ctx restate.WorkflowContext, user User) (bool, error)

func (SignupWorkflow) Click(ctx restate.WorkflowSharedContext, secret string) error {
// Send data to the workflow via a durable promise
return restate.Promise[string](ctx, "email-link").Resolve(secret)
return restate.Promise[string](ctx, "link-clicked").Resolve(secret)
}

func main() {
Expand Down
9 changes: 4 additions & 5 deletions java/basics/src/main/java/workflows/SignupWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import dev.restate.sdk.annotation.Shared;
import dev.restate.sdk.annotation.Workflow;
import dev.restate.sdk.common.DurablePromiseKey;
import dev.restate.sdk.common.StateKey;
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
import utils.User;

Expand All @@ -37,8 +36,8 @@
public class SignupWorkflow {

// References to K/V state and promises stored in Restate
private static final DurablePromiseKey<String> EMAIL_CLICKED =
DurablePromiseKey.of("email_clicked", JsonSerdes.STRING);
private static final DurablePromiseKey<String> LINK_CLICKED =
DurablePromiseKey.of("link_clicked", JsonSerdes.STRING);

// --- The workflow logic ---
@Workflow
Expand All @@ -56,7 +55,7 @@ public boolean run(WorkflowContext ctx, User user) {
// Wait until user clicked email verification link
// Promise gets resolved or rejected by the other handlers
String clickSecret =
ctx.promise(EMAIL_CLICKED)
ctx.promise(LINK_CLICKED)
.awaitable()
.await();

Expand All @@ -68,7 +67,7 @@ public boolean run(WorkflowContext ctx, User user) {
@Shared
public void click(SharedWorkflowContext ctx, String secret) {
// Send data to the workflow via a durable promise
ctx.promiseHandle(EMAIL_CLICKED).resolve(secret);
ctx.promiseHandle(LINK_CLICKED).resolve(secret);
}

public static void main(String[] args) {
Expand Down
7 changes: 3 additions & 4 deletions kotlin/basics/src/main/kotlin/workflows/SignupWorkflow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class SignupWorkflow {

companion object {
// References to K/V state and promises stored in Restate
private val EMAIL_CLICKED = KtDurablePromiseKey.json<String>("email_clicked")
private val ONBOARDING_STATUS = KtStateKey.json<String>("status")
private val LINK_CLICKED = KtDurablePromiseKey.json<String>("email_clicked")
}

@Workflow
Expand All @@ -40,7 +39,7 @@ class SignupWorkflow {
// Wait until user clicked email verification link
// Promise gets resolved or rejected by the other handlers
val clickSecret: String =
ctx.promise(EMAIL_CLICKED)
ctx.promise(LINK_CLICKED)
.awaitable()
.await()

Expand All @@ -51,7 +50,7 @@ class SignupWorkflow {
@Shared
suspend fun click(ctx: SharedWorkflowContext, secret: String) {
// Send data to the workflow via a durable promise
ctx.promiseHandle(EMAIL_CLICKED).resolve(secret)
ctx.promiseHandle(LINK_CLICKED).resolve(secret)
}
}

Expand Down
2 changes: 1 addition & 1 deletion kotlin/patterns-use-cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Use Restate as a queue. Schedule tasks for now or later and ensure the task is o
- The **send requests** put the tasks in Restate's queue. The task submitter does not wait for the task response.
- The **idempotency key** in the header is used by Restate to deduplicate requests.
- If a delay is set, the task will be executed later and Restate will track the timer durably, like a **delayed task queue**.
- [Async Task Worker](src/main/kotlin/my/example/queue/AsyncTaskService.kt): gets invoked by Restate for each task in the queue.
- [Async Task Worker](src/main/kotlin/my/example/queue/AsyncTaskWorker.kt): gets invoked by Restate for each task in the queue.

## Sagas
[<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg">](src/main/kotlin/my/example/sagas/BookingWorkflow.kt)
Expand Down
4 changes: 2 additions & 2 deletions python/basics/app/3_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ async def create_user():

# Wait until user clicked email verification link
# Promise gets resolved or rejected by the other handlers
click_secret = await ctx.promise("email_link").value()
click_secret = await ctx.promise("link_clicked").value()
return click_secret == secret


# --- Other handlers interact with the workflow via queries and signals ---
@user_signup.handler()
async def click(ctx: WorkflowSharedContext, secret: str):
# Send data to the workflow via a durable promise
await ctx.promise("email_link").resolve(secret)
await ctx.promise("link_clicked").resolve(secret)

app = restate.app(services=[user_signup])

Expand Down
4 changes: 2 additions & 2 deletions typescript/basics/src/3_workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const signupWorkflow = restate.workflow({

// Wait until user clicked email verification link
// Promise gets resolved or rejected by the other handlers
const clickSecret = await ctx.promise<string>("email-link");
const clickSecret = await ctx.promise<string>("link-clicked");
return clickSecret === secret;
},

Expand All @@ -42,7 +42,7 @@ const signupWorkflow = restate.workflow({
request: { secret: string },
) => {
// Send data to the workflow via a durable promise
await ctx.promise<string>("email-link").resolve(request.secret);
await ctx.promise<string>("link-clicked").resolve(request.secret);
},
},
});
Expand Down