Skip to content

Commit

Permalink
Update tutorial docs (#1889)
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonpi committed May 24, 2024
1 parent 73a34ff commit c596dfb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Sources/Examples/RouteGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ $ swift run RouteGuideClient

## Regenerating client and server code

For simplicity, a Makefile is provided in the root of this package with a target
For simplicity, a shell script ([grpc-swift/Protos/generate.sh][run-protoc]) is provided
to generate client and server code:

```sh
$ make generate-route-guide
$ Protos/generate.sh
```

[basic-tutorial]: ../../../docs/basic-tutorial.md
[run-protoc]: ../../../Protos/generate.sh
17 changes: 9 additions & 8 deletions docs/basic-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ $ cd grpc-swift/Sources/Examples/RouteGuide
Our first step (as you'll know from the [Overview][grpc-docs]) is to
define the gRPC *service* and the method *request* and *response* types using
[protocol buffers][protocol-buffers]. You can see the complete .proto file in
[`grpc-swift/Sources/Examples/RouteGuide/Model/route_guide.proto`][routeguide-proto].
[`grpc-swift/Protos/examples/route_guide/route_guide.proto`][routeguide-proto].

To define a service, we specify a named `service` in the .proto file:

Expand Down Expand Up @@ -142,12 +142,12 @@ Protobuf][swift-protobuf]) and the other for gRPC. You need to use the
[proto3][protobuf-releases] compiler (which supports both proto2 and proto3
syntax) in order to generate gRPC services.

For simplicity, we've provided a Makefile in the `grpc-swift` directory that
For simplicity, we've provided a shell script ([grpc-swift/Protos/generate.sh][run-protoc]) that
runs protoc for you with the appropriate plugin, input, and output (if you want
to run this yourself, make sure you've installed protoc first):

```sh
$ make generate-route-guide
$ Protos/generate.sh
```

Running this command generates the following files in the
Expand All @@ -161,8 +161,8 @@ Running this command generates the following files in the
Let's look at how to run the same command manually:

```sh
$ protoc Sources/Examples/RouteGuide/Model/route_guide.proto \
--proto_path=Sources/Examples/RouteGuide/Model \
$ protoc Protos/examples/route_guide/route_guide.proto \
--proto_path=Protos/examples/route_guide \
--plugin=./.build/debug/protoc-gen-swift \
--swift_opt=Visibility=Public \
--swift_out=Sources/Examples/RouteGuide/Model \
Expand Down Expand Up @@ -455,7 +455,7 @@ program from exiting (since `close()` is never called on the server).

In this section, we'll look at creating a Swift client for our `RouteGuide`
service. You can see our complete example client code in
[grpc-swift/Sources/Examples/RouteGuide/Client/main.swift][routeguide-client].
[grpc-swift/Sources/Examples/RouteGuide/Client/RouteGuideClient.swift][routeguide-client].

#### Creating a stub

Expand Down Expand Up @@ -604,10 +604,11 @@ Follow the instructions in the Route Guide example directory
[protobuf-docs]: https://developers.google.com/protocol-buffers/docs/proto3
[protobuf-releases]: https://github.com/google/protobuf/releases
[protocol-buffers]: https://developers.google.com/protocol-buffers/docs/overview
[routeguide-client]: ../Sources/Examples/RouteGuide/Client/main.swift
[routeguide-proto]: ../Sources/Examples/RouteGuide/Model/route_guide.proto
[routeguide-client]: ../Sources/Examples/RouteGuide/Client/RouteGuideClient.swift
[routeguide-proto]: ../Protos/examples/route_guide/route_guide.proto
[routeguide-provider]: ../Sources/Examples/RouteGuide/Server/RouteGuideProvider.swift
[routeguide-readme]: ../Sources/Examples/RouteGuide/README.md
[routeguide-source]: ../Sources/Examples/RouteGuide
[run-protoc]: ../Protos/generate.sh
[swift-protobuf-guide]: https://github.com/apple/swift-protobuf/blob/main/Documentation/API.md
[swift-protobuf]: https://github.com/apple/swift-protobuf
12 changes: 6 additions & 6 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#### Swift Version

gRPC requires Swift 5.0 or higher.
gRPC requires Swift 5.8 or higher.

#### Install Protocol Buffers v3
#### Install Protocol Buffers

Install the protoc compiler that is used to generate gRPC service code. The
simplest way to do this is to download pre-compiled binaries for your
Expand All @@ -27,8 +27,8 @@ clones the entire repository, but you just need the examples for this quickstart
and other tutorials):

```sh
$ # Clone the repository at the latest release to get the example code:
$ git clone -b 1.13.0 https://github.com/grpc/grpc-swift
$ # Clone the repository at the latest release to get the example code (replacing x.y.z with the latest release, for example 1.13.0):
$ git clone -b x.y.z https://github.com/grpc/grpc-swift
$ # Navigate to the repository
$ cd grpc-swift/
```
Expand Down Expand Up @@ -81,7 +81,7 @@ message HelloReply {
```

Let's update this so that the `Greeter` service has two methods. Edit
`Sources/Examples/HelloWorld/Model/helloworld.proto` and update it with a new
`Protos/upstream/grpc/examples/helloworld.proto` and update it with a new
`SayHelloAgain` method, with the same request and response types:

```proto
Expand Down Expand Up @@ -115,7 +115,7 @@ contains our generated gRPC client and server classes.
From the `grpc-swift` directory run

```sh
make generate-helloworld
$ Protos/generate.sh
```

This also regenerates classes for populating, serializing, and retrieving our
Expand Down

0 comments on commit c596dfb

Please sign in to comment.