Skip to content

Commit 6ddc281

Browse files
authored
Merge pull request #4953 from marcduiker/remove-rust-submodule
Move Rust SDK docs and remove submodule
2 parents 66e0741 + f4d9bf6 commit 6ddc281

File tree

6 files changed

+195
-7
lines changed

6 files changed

+195
-7
lines changed

.gitmodules

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
[submodule "translations/docs-zh"]
55
path = translations/docs-zh
66
url = https://github.com/dapr/docs-zh.git
7-
branch = v1.0_content
8-
[submodule "sdkdocs/rust"]
9-
path = sdkdocs/rust
10-
url = https://github.com/dapr/rust-sdk.git
7+
branch = v1.0_content

hugo.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ module:
308308
- source: sdkdocs/js/content/en/js-sdk-contributing
309309
target: content/contributing/sdk-contrib/
310310
lang: en
311-
- source: sdkdocs/rust/daprdocs/content/en/rust-sdk-docs
311+
- source: sdkdocs/rust/content/en/rust-sdk-docs
312312
target: content/developing-applications/sdks/rust
313313
lang: en
314-
- source: sdkdocs/rust/daprdocs/content/en/rust-sdk-contributing
314+
- source: sdkdocs/rust/content/en/rust-sdk-contributing
315315
target: content/contributing/sdk-contrib/
316316
lang: en
317317
- source: sdkdocs/pluggable-components/dotnet/content/en/dotnet-sdk-docs

sdkdocs/rust

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
type: docs
3+
title: "Contributing to the Rust SDK"
4+
linkTitle: "Rust SDK"
5+
weight: 3000
6+
description: Guidelines for contributing to the Dapr Rust SDK
7+
---
8+
9+
When contributing to the [Rust SDK](https://github.com/dapr/rust-sdk) the following rules and best-practices should be followed.
10+
11+
## Examples
12+
13+
The `examples` directory contains code samples for users to run to try out specific functionality of the various Rust SDK packages and extensions. It also hosts component examples used for validation. When writing new and updated samples keep in mind:
14+
15+
- All examples should be runnable on Windows, Linux, and MacOS. While Rust code is consistent among operating systems aside from minor OS-feature gating, any pre/post example commands should provide options through [tabpane]({{% ref "contributing-docs.md#tabbed-content" %}})
16+
- Contain steps to download/install any required pre-requisites. Someone coming in with a fresh OS install should be able to start on the example and complete it without an error. Links to external download pages are fine.
17+
- Examples should be pass validation and include mechanical markdown steps and be added to the validation workflow [TBA](#)
18+
19+
## Docs
20+
21+
The `daprdocs` directory contains the markdown files that are rendered into the [Dapr Docs](https://docs.dapr.io) website. When the documentation website is built this repo is cloned and configured so that its contents are rendered with the docs content. When writing docs keep in mind:
22+
23+
- All rules in the [docs guide]({{% ref contributing-docs.md %}}) should be followed in addition to these.
24+
- All files and directories should be prefixed with `rust-` to ensure all file/directory names are globally unique across all Dapr documentation.
25+
26+
## Update Protobufs
27+
28+
To pull the protobufs from the `dapr/dapr` repo you can run the script in the repo root like so:
29+
30+
```bash
31+
./update-protos.sh
32+
```
33+
34+
By default, the script fetches the latest proto updates from the master branch of the Dapr repository. If you need to choose a specific release or version, use the -v flag:
35+
36+
```bash
37+
./update-protos.sh -v v1.13.0
38+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
type: docs
3+
title: "Dapr Rust SDK"
4+
linkTitle: "Rust"
5+
weight: 1000
6+
description: Rust SDK packages for developing Dapr applications
7+
no_list: true
8+
cascade:
9+
github_repo: https://github.com/dapr/rust-sdk
10+
github_subdir: daprdocs/content/en/rust-sdk-docs
11+
path_base_for_github_subdir: content/en/developing-applications/sdks/rust/
12+
github_branch: main
13+
---
14+
15+
{{% alert title="Note" color="primary" %}}
16+
The Dapr Rust-SDK is currently in Alpha. Work is underway to bring it to a stable release and will likely involve breaking changes.
17+
{{% /alert %}}
18+
19+
A client library to help build Dapr applications using Rust. This client is targeting support for all public Dapr APIs while focusing on idiomatic Rust experiences and developer productivity.
20+
21+
{{% cardpane %}}
22+
{{% card title="**Client**" %}}
23+
Use the Rust Client SDK for invoking public Dapr APIs
24+
25+
[Learn more about the Rust Client SDK]({{% ref rust-client %}})
26+
{{% /card %}}
27+
{{% /cardpane %}}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
type: docs
3+
title: "Getting started with the Dapr client Rust SDK"
4+
linkTitle: "Client"
5+
weight: 20000
6+
description: How to get up and running with the Dapr Rust SDK
7+
no_list: true
8+
---
9+
10+
The Dapr client package allows you to interact with other Dapr applications from
11+
a Rust application.
12+
13+
{{% alert title="Note" color="primary" %}}
14+
The Dapr Rust-SDK is currently in Alpha. Work is underway to bring it to a
15+
stable release and will likely involve breaking changes.
16+
{{% /alert %}}
17+
18+
## Prerequisites
19+
20+
- [Dapr CLI]({{% ref install-dapr-cli.md %}}) installed
21+
- Initialized [Dapr environment]({{% ref install-dapr-selfhost.md %}})
22+
- [Rust installed](https://www.rust-lang.org/tools/install)
23+
24+
## Import the client package
25+
26+
Add Dapr to your `cargo.toml`
27+
28+
```toml
29+
[dependencies]
30+
dapr = "0.16"
31+
```
32+
33+
You can either reference `dapr::Client` or bind the full path to a new name as follows:
34+
35+
```rust
36+
use dapr::Client as DaprClient;
37+
```
38+
39+
## Instantiating the Dapr client
40+
41+
```rust
42+
let addr = "https://127.0.0.1".to_string();
43+
44+
let mut client = dapr::Client::<dapr::client::TonicClient>::connect(addr,
45+
port).await?;
46+
```
47+
48+
Alternatively if you would like to specify a custom port, this can be done by using this connect method:
49+
50+
```rust
51+
let mut client = dapr::Client::<dapr::client::TonicClient>::connect_with_port(addr, "3500".to_string()).await?;
52+
```
53+
54+
## Building blocks
55+
56+
The Rust SDK allows you to interface with the
57+
[Dapr building blocks]({{% ref building-blocks %}}).
58+
59+
### Service Invocation (gRPC)
60+
61+
To invoke a specific method on another service running with Dapr sidecar, the
62+
Dapr client provides two options:
63+
64+
Invoke a (gRPC) service
65+
66+
```rust
67+
let response = client
68+
.invoke_service("service-to-invoke", "method-to-invoke", Some(data))
69+
.await
70+
.unwrap();
71+
```
72+
73+
For a full guide on service invocation, visit
74+
[How-To: Invoke a service]({{% ref howto-invoke-discover-services.md %}}).
75+
76+
### State Management
77+
78+
The Dapr Client provides access to these state management methods: `save_state`
79+
, `get_state`, `delete_state` that can be used like so:
80+
81+
```rust
82+
let store_name = String::from("statestore");
83+
84+
let key = String::from("hello");
85+
let val = String::from("world").into_bytes();
86+
87+
// save key-value pair in the state store
88+
client
89+
.save_state(store_name, key, val, None, None, None)
90+
.await?;
91+
92+
let get_response = client
93+
.get_state("statestore", "hello", None)
94+
.await?;
95+
96+
// delete a value from the state store
97+
client
98+
.delete_state("statestore", "hello", None)
99+
.await?;
100+
```
101+
102+
Multiple states can be sent with the `save_bulk_states` method.
103+
104+
For a full guide on state management, visit
105+
[How-To: Save & get state]({{% ref howto-get-save-state.md %}}).
106+
107+
### Publish Messages
108+
109+
To publish data onto a topic, the Dapr client provides a simple method:
110+
111+
```rust
112+
let pubsub_name = "pubsub-name".to_string();
113+
let pubsub_topic = "topic-name".to_string();
114+
let pubsub_content_type = "text/plain".to_string();
115+
116+
let data = "content".to_string().into_bytes();
117+
client
118+
.publish_event(pubsub_name, pubsub_topic, pubsub_content_type, data, None)
119+
.await?;
120+
```
121+
122+
For a full guide on pub/sub, visit
123+
[How-To: Publish & subscribe]({{% ref howto-publish-subscribe.md %}}).
124+
125+
## Related links
126+
127+
[Rust SDK Examples](https://github.com/dapr/rust-sdk/tree/master/examples)

0 commit comments

Comments
 (0)