Skip to content

Commit d953a44

Browse files
authored
Add Server section to the Book (#1813)
* Move docs to server folder * Index the Server folder * Fix markdown lints * Add basic overview.md to server folder
1 parent 4ba6063 commit d953a44

File tree

5 files changed

+47
-34
lines changed

5 files changed

+47
-34
lines changed

design/src/SUMMARY.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Summary
2+
23
- [Design Overview](./overview.md)
34
- [Tenets](./tenets.md)
45
- [Design FAQ](./faq.md)
@@ -7,11 +8,16 @@
78
- [HTTP Middleware](transport/middleware.md)
89

910
- [Smithy](./smithy/overview.md)
10-
- [Simple Shapes](./smithy/simple_shapes.md)
11-
- [Recursive Shapes](./smithy/recursive_shapes.md)
12-
- [Aggregate Shapes](./smithy/aggregate_shapes.md)
13-
- [Endpoint Resolution](smithy/endpoint.md)
14-
- [Backwards Compatibility](smithy/backwards-compat.md)
11+
- [Simple Shapes](./smithy/simple_shapes.md)
12+
- [Recursive Shapes](./smithy/recursive_shapes.md)
13+
- [Aggregate Shapes](./smithy/aggregate_shapes.md)
14+
- [Endpoint Resolution](smithy/endpoint.md)
15+
- [Backwards Compatibility](smithy/backwards-compat.md)
16+
17+
- [Server](./server/overview.md)
18+
- [Generating Common Service Code](./server/code_generation.md)
19+
- [Generating the Pokémon Service](./server/pokemon_service.md)
20+
- [Instrumentation](./server/instrumentation.md)
1521

1622
- [RFCs](./rfcs/overview.md)
1723
- [RFC-0001: Sharing configuration between multiple clients](./rfcs/rfc0001_shared_config.md)

design/src/docs/code_generation.md renamed to design/src/server/code_generation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## Generating common service code
1+
# Generating Common Service Code
22

33
How a service is constructed and how to plug in new business logic is described in [Pokémon Service][1].
44
This document introduces the project and how code is being generated. It is written for developers who want to start contributing to `smithy-rs`.
55

6-
### Folder structure
6+
## Folder structure
77

88
The project is divided in:
99

@@ -15,7 +15,7 @@ which contains common functions used by other crates, [copied into][2] the sourc
1515

1616
`/rust-runtime` crates ("runtime crates") are added to a crate's dependency only when used. If a model uses event streams, it will depend on [`aws-smithy-eventstream`][3].
1717

18-
### Generating code
18+
## Generating code
1919

2020
`smithy-rs`'s entry points are Smithy code-generation plugins, and is not a command. One entry point is in [RustCodegenPlugin::execute][4] and
2121
inherits from `SmithyBuildPlugin` in [smithy-build][5]. Code generation is in Kotlin and shared common, non-Rust specific code with the [`smithy` Java repository][6]. They plug into the [Smithy gradle][7] plugin, which is a gradle plugin.

design/src/server/overview.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Smithy Server
2+
3+
Smithy Rust provides the ability to generate a server whose operations are provided by the customer.
4+
5+
- [Generating Common Service Code](./code_generation.md)
6+
- [Generating the Pokémon Service](./pokemon_service.md)
7+
- [Instrumentation](./instrumentation.md)

design/src/docs/pokemon_service.md renamed to design/src/server/pokemon_service.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Code generating the Pokémon Service
1+
# Generating the Pokémon Service
22

33
This is an overview of client and server of the Pokémon service. It introduces:
44

@@ -10,7 +10,7 @@ All the code shown and linked to is from the repository at this commit: [db48039
1010

1111
The Smithy model used to generate the code snippets is: [Pokémon][2]
1212

13-
### Building the service
13+
## Building the service
1414

1515
The entry point of a service is [main.rs][3]
1616

@@ -59,37 +59,37 @@ let app: Router = OperationRegistryBuilder::default()
5959

6060
Each of these operations is a function that can take any of these signatures.
6161

62-
1. If the operation is not fallible and does not share any state:
62+
1. If the operation is not fallible and does not share any state:
6363

64-
```rust
65-
pub async fn health_check_operation(_input: input::HealthCheckOperationInput) -> output::HealthCheckOperationOutput {...}
66-
```
64+
```rust
65+
pub async fn health_check_operation(_input: input::HealthCheckOperationInput) -> output::HealthCheckOperationOutput {...}
66+
```
6767

68-
2. If the operation is fallible and does not share any state:
68+
2. If the operation is fallible and does not share any state:
6969

70-
```rust
71-
pub async fn capture_pokemon(
72-
mut input: input::CapturePokemonOperationInput,
73-
) -> Result<output::CapturePokemonOperationOutput, error::CapturePokemonOperationError> {...}
74-
```
70+
```rust
71+
pub async fn capture_pokemon(
72+
mut input: input::CapturePokemonOperationInput,
73+
) -> Result<output::CapturePokemonOperationOutput, error::CapturePokemonOperationError> {...}
74+
```
7575

76-
3. If the operation is not fallible and shares some state:
76+
3. If the operation is not fallible and shares some state:
7777

78-
```rust
79-
pub async fn get_server_statistics(
80-
_input: input::GetServerStatisticsInput,
81-
state: Extension<Arc<State>>,
82-
) -> output::GetServerStatisticsOutput {...}
83-
```
78+
```rust
79+
pub async fn get_server_statistics(
80+
_input: input::GetServerStatisticsInput,
81+
state: Extension<Arc<State>>,
82+
) -> output::GetServerStatisticsOutput {...}
83+
```
8484

85-
4. If the operation is fallible and shares some state:
85+
4. If the operation is fallible and shares some state:
8686

87-
```rust
88-
pub async fn get_storage(
89-
input: input::GetStorageInput,
90-
_state: Extension<Arc<State>>,
91-
) -> Result<output::GetStorageOutput, error::GetStorageError> {...}
92-
```
87+
```rust
88+
pub async fn get_storage(
89+
input: input::GetStorageInput,
90+
_state: Extension<Arc<State>>,
91+
) -> Result<output::GetStorageOutput, error::GetStorageError> {...}
92+
```
9393

9494
All of these are operations which implementors define; they are the business logic of the application. The rest is code generated.
9595

0 commit comments

Comments
 (0)