-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add docs for volo-http and refactor volo directories (#1125)
- Loading branch information
1 parent
6235b19
commit da93d0f
Showing
43 changed files
with
2,832 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: "Cli" | ||
linkTitle: "Cli" | ||
weight: 2 | ||
keywords: ["Rust", "Volo", "cli"] | ||
description: "Volo-cli Usage" | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
--- | ||
title: "Getting Started" | ||
linkTitle: "Getting Started" | ||
weight: 2 | ||
keywords: ["Volo", "cli", "Tutorial", "Install"] | ||
description: "This document covers the preparation of the development environment, quick start and basic tutorials of Volo-HTTP." | ||
--- | ||
|
||
Volo provides CLI tools of the same name, and it provide functions as follows: | ||
|
||
1. Server-side scaffold generation | ||
|
||
support generate HTTP or RPC server-side scaffold by IDL like Thrift, Protobuf | ||
|
||
2. Stub management | ||
|
||
3. Old version migration | ||
|
||
## Part 1. Install Cli tool | ||
|
||
```bash | ||
cargo install volo-cli | ||
``` | ||
|
||
Need rustc version >= 1.80.0 | ||
|
||
Then, we type: | ||
|
||
```bash | ||
volo help | ||
``` | ||
|
||
and we can see the output as follows: | ||
|
||
```plain | ||
Usage: volo [OPTIONS] <COMMAND> | ||
Commands: | ||
init init your thrift or grpc project | ||
http manage your http project | ||
repo manage your repo | ||
idl manage your idl | ||
migrate migrate your config from old version | ||
help Print this message or the help of the given subcommand(s) | ||
Options: | ||
-v, --verbose... Turn on the verbose mode. | ||
-n, --entry-name <ENTRY_NAME> The entry name, defaults to 'default'. [default: default] | ||
-h, --help Print help | ||
-V, --version Print version | ||
``` | ||
|
||
## Part 2. Generate RPC code | ||
|
||
To create a RPC project, we need to write an IDL first. Let's take Thrift for example. | ||
|
||
|
||
Create a new Thrift IDL in the project directory: | ||
|
||
`vim idl/rpc_example.thrift` | ||
|
||
```thrift | ||
namespace rs volo.rpc.example | ||
struct Item { | ||
1: required i64 id, | ||
2: required string title, | ||
3: required string content, | ||
10: optional map<string, string> extra, | ||
} | ||
struct GetItemRequest { | ||
1: required i64 id, | ||
} | ||
struct GetItemResponse { | ||
1: required Item item, | ||
} | ||
service ItemService { | ||
GetItemResponse GetItem (1: GetItemRequest req), | ||
} | ||
``` | ||
|
||
Execute the following command: | ||
|
||
`volo init volo-rpc-example idl/rpc_example.thrift` | ||
|
||
At this point, our entire catalog is structured as follows: | ||
|
||
```plain | ||
. | ||
├── Cargo.toml | ||
├── idl | ||
│ └── rpc_example.thrift | ||
├── rust-toolchain.toml | ||
├── src | ||
│ ├── bin | ||
│ │ └── server.rs | ||
│ └── lib.rs | ||
└── volo-gen | ||
├── Cargo.toml | ||
├── build.rs | ||
├── src | ||
│ └── lib.rs | ||
└── volo.yml | ||
``` | ||
|
||
## Part 2. Generate HTTP code | ||
|
||
Execute the following command: | ||
|
||
`volo http init volo-http-example` | ||
|
||
At this point, our entire catalog is structured as follows: | ||
|
||
```bash | ||
$ tree | ||
. | ||
├── Cargo.toml | ||
└── src | ||
├── bin | ||
│ └── server.rs | ||
└── lib.rs | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: "Migrate" | ||
linkTitle: "Migrate" | ||
weight: 4 | ||
keywords: ["Volo", "cli", "Migrate"] | ||
description: "Volo-Cli Migrate" | ||
--- | ||
|
||
Migrating from an older version of `volo.yml` to the current version of `volo.yml` | ||
|
||
```bash | ||
Usage: volo migrate [OPTIONS] | ||
|
||
Options: | ||
-v, --verbose... Turn on the verbose mode. | ||
-h, --help Print help | ||
-V, --version Print version | ||
``` | ||
|
||
## How to migrate? | ||
|
||
1. Switch to the root directory of the project (where `volo.yml` is located). | ||
2. Run the command `volo migrate` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: "Guide" | ||
linkTitle: "Guide" | ||
weight: 4 | ||
weight: 6 | ||
description: Project usage guide. | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: "Volo-gRPC" | ||
linkTitle: "Volo-gRPC" | ||
weight: 3 | ||
weight: 5 | ||
keywords: ["Volo", "gRPC", "Getting Started", "Guidelines"] | ||
description: "CLI tool installation, quick start and basic tutorials for Volo-gRPC." | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: "Volo-HTTP" | ||
linkTitle: "Volo-HTTP" | ||
weight: 3 | ||
keywords: ["Volo", "HTTP", "Getting started", "Tutorials"] | ||
description: "Volo-HTTP Tutorials。" | ||
--- |
Oops, something went wrong.