Skip to content

Commit 5e4ea56

Browse files
committed
Update Example READMEs
Motivation: The examples now use the Swift PM build plugin but the READMEs weren't updated to include the PROTOC_PATH. Modifications: - update READMEs Result: Better examples
1 parent f7261ad commit 5e4ea56

File tree

5 files changed

+45
-10
lines changed

5 files changed

+45
-10
lines changed

Examples/echo/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,32 @@ the four RPC types.
1212
The tool uses the [SwiftNIO](https://github.com/grpc/grpc-swift-nio-transport)
1313
HTTP/2 transport.
1414

15+
## Prerequisites
16+
17+
You must have the Protocol Buffers compiler (`protoc`) installed. You can find
18+
the instructions for doing this in the [gRPC Swift Protobuf documentation][0].
19+
1520
## Usage
1621

1722
Build and run the server using the CLI:
1823

1924
```console
20-
$ swift run echo serve
25+
$ PROTOC_PATH=$(which protoc) swift run echo serve
2126
Echo listening on [ipv4]127.0.0.1:1234
2227
```
2328

2429
Use the CLI to make a unary 'Get' request against it:
2530

2631
```console
27-
$ swift run echo get --message "Hello"
32+
$ PROTOC_PATH=$(which protoc) swift run echo get --message "Hello"
2833
get → Hello
2934
get ← Hello
3035
```
3136

3237
Use the CLI to make a bidirectional streaming 'Update' request:
3338

3439
```console
35-
$ swift run echo update --message "Hello World"
40+
$ PROTOC_PATH=$(which protoc) swift run echo update --message "Hello World"
3641
update → Hello
3742
update → World
3843
update ← Hello
@@ -42,5 +47,7 @@ update ← World
4247
Get help with the CLI by running:
4348

4449
```console
45-
$ swift run echo --help
50+
$ PROTOC_PATH=$(which protoc) swift run echo --help
4651
```
52+
53+
[0]: https://swiftpackageindex.com/grpc/grpc-swift-protobuf/documentation/grpcprotobuf/installing-protoc

Examples/error-details/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ described in more detailed in the [gRPC Error
1010
Guide](https://grpc.io/docs/guides/error/) and is made available via the
1111
[grpc-swift-protobuf](https://github.com/grpc-swift-protobuf) package.
1212

13+
## Prerequisites
14+
15+
You must have the Protocol Buffers compiler (`protoc`) installed. You can find
16+
the instructions for doing this in the [gRPC Swift Protobuf documentation][0].
17+
1318
## Usage
1419

1520
Build and run the example using the CLI:
1621

1722
```console
18-
$ swift run
23+
$ PROTOC_PATH=$(which protoc) swift run
1924
Error code: resourceExhausted
2025
Error message: The greeter has temporarily run out of greetings.
2126
Error details:
@@ -24,3 +29,5 @@ Error details:
2429
- Help links:
2530
- https://en.wikipedia.org/wiki/Caffeine (A Wikipedia page about caffeine including its properties and effects.)
2631
```
32+
33+
[0]: https://swiftpackageindex.com/grpc/grpc-swift-protobuf/documentation/grpcprotobuf/installing-protoc

Examples/hello-world/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,32 @@ service which allows you to start a server and to make requests against it.
1010
The tool uses the [SwiftNIO](https://github.com/grpc/grpc-swift-nio-transport)
1111
HTTP/2 transport.
1212

13+
## Prerequisites
14+
15+
You must have the Protocol Buffers compiler (`protoc`) installed. You can find
16+
the instructions for doing this in the [gRPC Swift Protobuf documentation][0].
17+
1318
## Usage
1419

1520
Build and run the server using the CLI:
1621

1722
```console
18-
$ swift run hello-world serve
23+
$ PROTOC_PATH=$(which protoc) swift run hello-world serve
1924
Greeter listening on [ipv4]127.0.0.1:31415
2025
```
2126

2227
Use the CLI to send a request to the service:
2328

2429
```console
25-
$ swift run hello-world greet
30+
$ PROTOC_PATH=$(which protoc) swift run hello-world greet
2631
Hello, stranger
2732
```
2833

2934
Send the name of the greetee in the request by specifying a `--name`:
3035

3136
```console
32-
$ swift run hello-world greet --name "PanCakes 🐶"
37+
$ PROTOC_PATH=$(which protoc) swift run hello-world greet --name "PanCakes 🐶"
3338
Hello, PanCakes 🐶
3439
```
40+
41+
[0]: https://swiftpackageindex.com/grpc/grpc-swift-protobuf/documentation/grpcprotobuf/installing-protoc

Examples/reflection-server/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ protoc --descriptor_set_out=path/to/output.pb path/to/input.proto \
2323
--include_imports
2424
```
2525

26+
## Prerequisites
27+
28+
You must have the Protocol Buffers compiler (`protoc`) installed. You can find
29+
the instructions for doing this in the [gRPC Swift Protobuf documentation][0].
30+
2631
## Usage
2732

2833
Build and run the server using the CLI:
@@ -59,3 +64,5 @@ $ grpcurl -plaintext -d '{ "text": "Hello" }' 127.0.0.1:31415 echo.Echo.Get
5964
"text": "Hello"
6065
}
6166
```
67+
68+
[0]: https://swiftpackageindex.com/grpc/grpc-swift-protobuf/documentation/grpcprotobuf/installing-protoc

Examples/route-guide/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,24 @@ HTTP/2 transport.
1515
This example has an accompanying tutorial hosted on the [Swift Package
1616
Index](https://swiftpackageindex.com/grpc/grpc-swift/main/tutorials/grpccore/route-guide).
1717

18+
## Prerequisites
19+
20+
You must have the Protocol Buffers compiler (`protoc`) installed. You can find
21+
the instructions for doing this in the [gRPC Swift Protobuf documentation][0].
22+
1823
## Usage
1924

2025
Build and run the server using the CLI:
2126

2227
```console
23-
$ swift run route-guide serve
28+
$ PROTOC_PATH=$(which protoc) swift run route-guide serve
2429
server listening on [ipv4]127.0.0.1:31415
2530
```
2631

2732
Use the CLI to interrogate the different RPCs you can call:
2833

2934
```console
30-
$ swift run route-guide --help
35+
$ PROTOC_PATH=$(which protoc) swift run route-guide --help
3136
USAGE: route-guide <subcommand>
3237

3338
OPTIONS:
@@ -42,3 +47,5 @@ SUBCOMMANDS:
4247

4348
See 'route-guide help <subcommand>' for detailed help.
4449
```
50+
51+
[0]: https://swiftpackageindex.com/grpc/grpc-swift-protobuf/documentation/grpcprotobuf/installing-protoc

0 commit comments

Comments
 (0)