Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 3.01 KB

README.md

File metadata and controls

66 lines (49 loc) · 3.01 KB

Examples of the basic concepts for Restate in Kotlin

The examples here showcase the most basic building blocks of Restate. Durable Execution, Durable Promises, and Virtual Objects, and the Workflows abstraction built on top of them.

The individual example files contain code snippets with comments and a brief descriptions about how they work and how they can be run.

Examples

  • Basic Durable Execution:: Running code cleanly to the end in the presence of failures. Automatic retries and recovery of previously finished actions. The example applies a series of updates and permission setting changes to user's profile.

    ./gradlew -PmainClass=durable_execution.RoleUpdateServiceKt run
  • Durable Execution with Compensations: Reliably compensating / undoing previous actions upon unrecoverable errors halfway through multi-step change. This is the same example as above, extended for cases where a part of the change cannot be applied (conflict) and everything has to roll back.

    ./gradlew -PmainClass=durable_execution_compensation.RoleUpdateServiceKt run
  • Workflows: Workflows are durable execution tasks that can be submitted and awaited. They have an identity and can be signaled and queried through durable promises. The example is a user-signup flow that takes multiple operations, including verifying the email address.

  • Virtual Objects: Stateful serverless objects to manage durable consistent state and state-manipulating logic.

    ./gradlew -PmainClass=virtual_objects.GreeterObjectKt run
  • Kafka Event-processing: Processing events to update various downstream systems with durable event handlers, event-delaying, in a strict-per-key order.

    ./gradlew -PmainClass=events_processing.UserUpdatesServiceKt run
  • Stateful Event-processing: Populating state from events and making is queryable via RPC handlers.

    ./gradlew -PmainClass=events_state.ProfileServiceKt run

Running the examples

  1. Start Restate Server in a separate shell: npx restate-server

  2. Start the relevant example. The commands are listed above for each example.

  3. Register the example at Restate server by calling npx restate -y deployment register --force localhost:9080.

    Note: the '--force' flag here is to circumvent all checks related to graceful upgrades, because it is only a playground, not a production setup.

  4. Check the comments in the example for how to interact with the example.

NOTE: When you get an error of the type {"code":"not_found","message":"Service 'greeter' not found. ...}, then you forgot step (3) for that example.