Skip to content

Commit

Permalink
Rust quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Sep 10, 2024
1 parent 86eb292 commit 7c30639
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
122 changes: 122 additions & 0 deletions docs/get_started/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,128 @@ This guide takes you through your first steps with Restate.
<Step end={true} stepLabel="🎉" title="Congratulations, you managed to run your first Restate service!"/>


</TabItem>
<TabItem value="rust" label="Rust" default>

<Admonition type="note" title="Prerequisites">
- [Rust](https://rustup.rs/)
- [Restate Server & CLI](/develop/local_dev#running-restate-server--cli-locally)
</Admonition>

<Step stepLabel="1" title="Get the Greeter service template">

<CH.Code>
```shell CLI
# link(1:3) /develop/local_dev#running-restate-server--cli-locally
restate example rust-hello-world &&
cd rust-hello-world
```

```shell wget
wget https://github.com/restatedev/examples/releases/latest/download/rust-hello-world.zip &&
unzip rust-hello-world.zip -d rust-hello-world &&
rm rust-hello-world.zip && cd rust-hello-world
```

```shell npx
npx @restatedev/restate example rust-hello-world &&
cd rust-hello-world
```

</CH.Code>

</Step>
<Step stepLabel="2" title="Run the Greeter service">

Use `cargo run` to build and run the example:

```shell
cargo run
```

</Step>

<Step stepLabel="3" title="Launch Restate">
Restate is a single self-contained binary. No external dependencies needed. Run it locally via ([or download the binaries](/develop/local_dev#running-restate-server--cli-locally)):


<CH.Code rows={"2"}>

``` shell Homebrew
brew install restatedev/tap/restate-server && restate-server
```

```shell Docker
docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 \
--add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:VAR::RESTATE_VERSION
```

```shell npx
npx @restatedev/restate-server
```

</CH.Code>

</Step>

<Step stepLabel="4" title="Register the service">

Tell Restate where the service is running, so Restate can discover and register the services and handlers behind this endpoint:

<CH.Code rows={"2"}>

```shell CLI
# link /develop/local_dev#running-restate-server--cli-locally
restate deployments register http://localhost:9080
```

```shell curl
curl localhost:9070/deployments -H 'content-type: application/json' \
-d '{"uri": "http://localhost:9080"}'
```

```shell npx
npx @restatedev/restate deployments register http://localhost:9080
```

</CH.Code>

If you run Restate with Docker, use `http://host.docker.internal:9080` instead of `http://localhost:9080`.

<details className={"grey-details"}>

<summary>Output</summary>

```shell
❯ SERVICES THAT WILL BE ADDED:
- Greeter
Type: Service
HANDLER INPUT OUTPUT
greet value of content-type 'application/json' value of content-type 'application/json'
✔ Are you sure you want to apply those changes? · yes
✅ DEPLOYMENT:
SERVICE REV
Greeter 1
```

</details>

</Step>

<Step stepLabel="5" title="Send a request to the Greeter service">

```shell
curl localhost:8080/Greeter/greet -H 'content-type: application/json' -d '"Francesco"'
```

You should now see printed as response: `"Greetings Francesco"`

</Step>
<Step end={true} stepLabel="🎉" title="Congratulations, you managed to run your first Restate service!"/>


</TabItem>
</Tabs>

Expand Down
4 changes: 4 additions & 0 deletions docs/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ alt="Go Quickstart"></img></a></div>
href="/get_started/quickstart?sdk=python"
role="button"><img className="buttonIcon" src="/img/python.svg" width="26"
alt="Python Quickstart"></img></a></div>
<div id="overviewButtonDiv"><a className="overviewButton btn btn-primary btn-lg firstTimeButton"
href="/get_started/quickstart?sdk=rust"
role="button"><img className="buttonIcon" src="/img/rust.svg" width="26"
alt="Rust Quickstart"></img></a></div>
</>
),
},
Expand Down
7 changes: 7 additions & 0 deletions static/img/rust.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c30639

Please sign in to comment.