Skip to content

Commit 616cd77

Browse files
timClickscrisidevdavid-perez
authored andcommitted
Expand example documentation (#2570)
## Motivation and Context The current README for the example services is fairly spartan. ## Description I've expanded the README, specifically: - Clean up some markup - Document pre-reqs. - Document all make targets. - Avoid the $BINARY because it looks like a bash variable. - Expand intro ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> n/a ## Checklist n/a ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com> Co-authored-by: david-perez <d@vidp.dev>
1 parent 540545a commit 616cd77

File tree

1 file changed

+59
-20
lines changed

1 file changed

+59
-20
lines changed

examples/README.md

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,88 @@
11
# Smithy Rust Server SDK examples
22

3-
This folder contains an example services showcasing the service framework capabilities and to run benchmarks.
3+
This folder contains some example services showcasing Smithy Rust Server SDK,
4+
also known as the Rust service framework, capabilities and to run benchmarks.
45

5-
- `/pokemon-service`, a HTTP server implementation demonstrating [middleware](https://awslabs.github.io/smithy-rs/design/server/middleware.html)
6-
and [extractors](https://awslabs.github.io/smithy-rs/design/server/from_parts.html).
7-
- `/pokemon-service-tls`, a minimal HTTPS server implementation.
8-
- `/pokemon-service-lambda`, a minimal Lambda deployment.
6+
Three server implementations are available:
97

10-
The `/{binary}/tests` folders are integration tests involving the generated clients.
8+
- `/pokemon-service`, a HTTP server demonstrating [middleware] and [extractors].
9+
- `/pokemon-service-tls`, a HTTPS server. This server can do
10+
its own TLS negotiation, rather than relying on a load balancer.
11+
- `/pokemon-service-lambda`, a server that can be deployed onto AWS Lambda.
1112

12-
## Build
13+
These servers, and their clients, are generated using smithy-rs. You're invited
14+
to benchmark the performance of these servers to see whether smithy-rs might be
15+
a suitable choice for implementing your web service.
1316

14-
Since this example requires both the server and client SDK to be code-generated
17+
[middleware]: https://awslabs.github.io/smithy-rs/design/server/middleware.html
18+
[extractors]: https://awslabs.github.io/smithy-rs/design/server/from_parts.html
19+
20+
21+
## Pre-requisites
22+
23+
You will need install Java 11 to run the smithy-rs code generator and an
24+
installation of Rust, including `cargo`, to compile the generated code.
25+
26+
(Optional) The [Cargo Lambda](https://cargo-lambda.info/) sub-command for
27+
`cargo` is required to support the AWS Lambda integration.
28+
29+
30+
## Building
31+
32+
Since these examples require both the server and client SDK to be code-generated
1533
from their [model](/codegen-server-test/model/pokemon.smithy), a Makefile is
1634
provided to build and run the service. Just run `make` to prepare the first
1735
build.
1836

1937
Once the example has been built successfully the first time, idiomatic `cargo`
2038
can be used directly.
2139

22-
`make distclean` can be used for a complete cleanup of all artefacts.
40+
### Make targets:
41+
42+
- `codegen`: generates the Pokémon service crates (default)
43+
- `build`: compiles the generated client and server
44+
- `clean`: deletes build artifacts
45+
- `clippy`: lints the code
46+
- `distclean`: delete generated code and build artifacts
47+
- `doc-open`: builds and opens the rustdoc documentation
48+
- `lambda_invoke`: invokes a running server
49+
- `lambda_watch`: runs the service on an emulated AWS Lambda environment
50+
- `run`: runs the Pokémon service
51+
- `test`: runs integration and unit tests
52+
2353

24-
## Run
54+
## Running services
2555

26-
To run a binary use
56+
To run one of the three server implementations locally, provide the appropriate
57+
service name to the `--bin` flag:
2758

2859
```bash
29-
cargo run -p $BINARY
60+
cargo run --bin pokemon-service[(-lambda|-tls)]
3061
```
3162

32-
CLI arguments can be passed to the servers, use
63+
CLI arguments can be passed to the server binaries by adding them after `--`.
64+
For example, to see a service's help information, use the following:
3365

3466
```bash
35-
cargo run -p $BINARY -- --help
67+
cargo run --bin <service> -- --help
3668
```
3769

38-
for more information.
70+
## Testing
3971

40-
## Test
72+
The `/pokemon-test*/tests` folders provide integration tests involving the
73+
generated clients.
4174

42-
`cargo test` can be used to spawn a service and run some simple integration
43-
tests against it. Use `-p $BINARY` to filter by package.
75+
They can be invoked with `cargo test`. This will spawn each service in turn
76+
and run some integration tests against it. Use `-p <package>` to filter by
77+
package.
4478

4579
More info can be found in the `tests` folder of each package.
4680

47-
## Benchmarks
4881

49-
Please see [BENCHMARKS.md](/examples/BENCHMARKS.md).
82+
## Benchmarking
83+
84+
Servers running locally (see "Running services") can be benchmarked with any
85+
load testing tool, such as Artillery or `wrk`.
86+
87+
Please see [BENCHMARKS.md](/examples/BENCHMARKS.md) for benchmarking results
88+
produced by the smithy-rs team.

0 commit comments

Comments
 (0)