Skip to content

Commit

Permalink
Python quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen committed Sep 9, 2024
1 parent 7b068cf commit 15f84f1
Show file tree
Hide file tree
Showing 21 changed files with 1,198 additions and 1,213 deletions.
2 changes: 1 addition & 1 deletion code_snippets/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/aws/aws-lambda-go v1.47.0
github.com/awslabs/aws-lambda-go-api-proxy v0.16.2
github.com/restatedev/examples/tutorials/tour-of-restate-go v0.0.0-20240822081842-d36fec58c6cf
github.com/restatedev/sdk-go v0.11.0
github.com/restatedev/sdk-go v0.10.1-0.20240822083433-0d57a0aef17b
google.golang.org/protobuf v1.34.2
)

Expand Down
4 changes: 2 additions & 2 deletions code_snippets/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/restatedev/examples/tutorials/tour-of-restate-go v0.0.0-20240822081842-d36fec58c6cf h1:biOe8TVlMe0wnsXjmOBZPZJUvJclvPMAa2LysiH2oJY=
github.com/restatedev/examples/tutorials/tour-of-restate-go v0.0.0-20240822081842-d36fec58c6cf/go.mod h1:K0LyoiZk9ZKsNHJiPpfV80AOzX9MU+d26YTXHlY0qjk=
github.com/restatedev/sdk-go v0.11.0 h1:5pN5XSlTxJBWHZEuY0fZPorKU6xncz5CPGnnCChgjxg=
github.com/restatedev/sdk-go v0.11.0/go.mod h1:6gHoU8pyP7YQfFWxKG2u94u/TSGen0qN7BWowWNDw4Y=
github.com/restatedev/sdk-go v0.10.1-0.20240822083433-0d57a0aef17b h1:d+w/Ch3tIZtJ0v2qyucNTWOujrh+3/NZBOFw5qj/8UE=
github.com/restatedev/sdk-go v0.10.1-0.20240822083433-0d57a0aef17b/go.mod h1:6gHoU8pyP7YQfFWxKG2u94u/TSGen0qN7BWowWNDw4Y=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
Expand Down
1,722 changes: 868 additions & 854 deletions code_snippets/ts/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions code_snippets/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
},
"dependencies": {
"@restatedev/restate-cdk": "^1.0.0",
"@restatedev/restate-sdk": "^1.3.0",
"@restatedev/restate-sdk-clients": "^1.3.0",
"@restatedev/restate-sdk": "^1.0.0",
"@restatedev/restate-sdk-clients": "^1.0.0",
"express": "^4.19.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions code_snippets/ts/src/concepts/invocations/delayed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ async function myRestateHandler(ctx: restate.Context) {
// focus
ctx
// focus
.serviceSendClient(greeter)
.serviceSendClient(greeter, { delay: 1000 })
// focus
.greet({ greeting: "Hi" }, restate.rpc.sendOpts({ delay: 1000 }));
.greet({ greeting: "Hi" });
}
// <end_delayed_call>
5 changes: 3 additions & 2 deletions code_snippets/ts/src/concepts/invocations/ingress/delayed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as restate from "@restatedev/restate-sdk-clients";
import { greeter } from "../utils";
import { greetCounter, greeter } from "../utils";
import { SendOpts } from "@restatedev/restate-sdk-clients";

// <start_delayed_call_node>
const myPlainTSFunction = async () => {
Expand All @@ -10,6 +11,6 @@ const myPlainTSFunction = async () => {
// focus
.serviceSendClient(greeter)
// focus
.greet({ greeting: "Hi" }, restate.rpc.sendOpts({ delay: 1000 }));
.greet({ greeting: "Hi" }, SendOpts.from({ delay: 1000 }));
};
// <end_delayed_call_node>
9 changes: 5 additions & 4 deletions code_snippets/ts/src/develop/clients/ingress.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { greetCounterObject, greeterService } from "./utils";
import { SendOpts } from "@restatedev/restate-sdk-clients";
import { myWorkflow } from "../../concepts/invocations/utils";
import * as clients from "@restatedev/restate-sdk-clients";

Expand Down Expand Up @@ -34,11 +35,11 @@ const myPlainTSFunction3 = async () => {
const rs = clients.connect({ url: "http://localhost:8080" });
await rs
.serviceSendClient(greeterService)
.greet({ greeting: "Hi" }, clients.rpc.sendOpts({ delay: 1000 }));
.greet({ greeting: "Hi" }, SendOpts.from({ delay: 1000 }));

await rs
.objectSendClient(greetCounterObject, "Mary")
.greet({ greeting: "Hi" }, clients.rpc.sendOpts({ delay: 1000 }));
.greet({ greeting: "Hi" }, SendOpts.from({ delay: 1000 }));
// <end_delayed_call_node>
};

Expand All @@ -49,7 +50,7 @@ const servicesIdempotent = async () => {
await rs
.serviceSendClient(greeterService)
// withClass highlight-line
.greet(request, clients.rpc.sendOpts({ idempotencyKey: "abcde" }));
.greet(request, SendOpts.from({ idempotencyKey: "abcde" }));
// <end_service_idempotent>
};

Expand All @@ -62,7 +63,7 @@ const servicesAttach = async () => {
const handle = await rs
.serviceSendClient(greeterService)
// mark
.greet(request, clients.rpc.sendOpts({ idempotencyKey: "abcde" }));
.greet(request, SendOpts.from({ idempotencyKey: "abcde" }));

// ... do something else ...

Expand Down
46 changes: 0 additions & 46 deletions code_snippets/ts/src/develop/serialization.ts

This file was deleted.

6 changes: 3 additions & 3 deletions code_snippets/ts/src/develop/service_communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const service = restate.service({
// <end_one_way_object>

// <start_delayed_service>
ctx.serviceSendClient(MyService).myHandler("Hi", restate.rpc.sendOpts({ delay: 5000 }));
ctx.serviceSendClient(MyService, { delay: 5000 }).myHandler("Hi");
// <end_delayed_service>

// <start_delayed_object>
ctx
.objectSendClient(MyVirtualObject, "Mary")
.myHandler("Hi", restate.rpc.sendOpts({ delay: 5000 }));
.objectSendClient(MyVirtualObject, "Mary", { delay: 5000 })
.myHandler("Hi");
// <end_delayed_object>

// <start_ordering>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function submitAndAwaitTask(task: TaskOpts) {
.runTask(
task,
// <mark_2>
restate.rpc.sendOpts({ idempotencyKey: "dQw4w9WgXcQ" })
SendOpts.from({ idempotencyKey: "dQw4w9WgXcQ" })
// </mark_2>
);
// </mark_1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const eventEnricher = restate.object({
ctx.set("user", event);
// </mark_1>
// <mark_3>
ctx.objectSendClient(EventEnricher, ctx.key).emit(restate.rpc.sendOpts({ delay: 1000 }));
ctx.objectSendClient(EventEnricher, ctx.key, { delay: 1000 }).emit();
// </mark_3>
},

Expand Down
9 changes: 7 additions & 2 deletions docs/deploy/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import Admonition from '@theme/Admonition';

# Restate Cloud

[Restate Cloud](https://restate.dev/cloud) is a fully managed serverless version of Restate, with a suite of tools supporting a stellar local development experience, and security features like [request signing](#securing-your-services) and [IAM roles for AWS Lambda](#aws-lambda-services). This allows you to focus on your services, which you can deploy wherever you normally do, while Restate Cloud handles all aspects of availability and durability for your invocations, workflows, and state.
<Admonition type="warning">
Restate Cloud free tier is in early access and we don't offer strict
availability or durability SLAs at this time.
</Admonition>

[Restate Cloud](https://cloud.restate.dev) is the early-access managed service of Restate, where we run an instance of the Restate server for you. This allows you to focus on your services, which you can deploy wherever you normally do - long-lived compute, or serverless platforms like Lambda.

## Creating your first environment

Expand Down Expand Up @@ -63,7 +68,7 @@ identity in the same account that the Lambda is deployed to. Create a new role
that has permission to invoke your Lambda handlers, and give it the following
trust policy.

<Admonition type="info">
<Admonition type="warning">
The Restate Cloud role is distinct from the Lambda function's execution role.
The execution role is assumed by your function to perform its work. A dedicated
invoker role is needed to grant Restate Cloud permission to invoke service handler
Expand Down
4 changes: 2 additions & 2 deletions docs/develop/go/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ CODE_LOAD::go/develop/myservice/main.go
- By default, the service name is the name of the struct, so the service can be
called at `<RESTATE_INGRESS_URL>/MyService/MyHandler`.
- The service definition contains a list of handlers.
Each handler is just function that implements the handler logic. The handler
Each handler is just a function that implements the handler logic. The handler
will be named the same way as the method.
The function has the Restate Context as its first argument.
Within the handler, you use the `Context` to interact with Restate.
The SDK stores the actions you do on the context in the Restate journal to make them durable.
- The handler input parameters and return type can be of any type, as long as
- The handler input parameter (at most one) and return type can be of any type, as long as
they can be serialized. By default, serialization is done with
[`JSONCodec`](https://pkg.go.dev/github.com/restatedev/sdk-go/encoding#PayloadCodec)
which uses `encoding/json`. Input types, output types, and even errors are not mandatory
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/java/clients.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Invoke a handler programmatically with the SDK clients as follows:

<Step stepLabel="1" title="Add the dependency to your project">
```kotlin
implementation("dev.restate:sdk-common:VAR::JAVA_SDK_VERSION")
implementation("dev.restate:sdk-common:VAR::TYPESCRIPT_SDK_VERSION")
```
</Step>
<Step stepLabel="2" title={<span><a href={"/operate/registration"}>Register the service</a> you want to invoke.</span>}/>
Expand Down
43 changes: 0 additions & 43 deletions docs/develop/ts/serialization.mdx

This file was deleted.

Loading

0 comments on commit 15f84f1

Please sign in to comment.