mirror of https://github.com/grpc/grpc.io.git
feat: move the $ shell line indicator to scss (#1354)
This commit is contained in:
parent
e2bace833a
commit
ab8b3af6dd
|
@ -154,6 +154,32 @@ body:not(.td-blog) .td-content:not(.list-page) {
|
|||
}
|
||||
}
|
||||
|
||||
// Render the bash $ prefix indicator to enable easier copy of cli commands
|
||||
.td-content div.highlight pre {
|
||||
padding-left: 0.5rem;
|
||||
code.language-sh:before {
|
||||
content: "$";
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
code.language-sh span {
|
||||
display: inline !important;
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Render the powershell > prefix indicator to enable easier copy of cli commands
|
||||
.td-content div.highlight pre {
|
||||
padding-left: 0.5rem;
|
||||
code.language-powershell:before {
|
||||
content: ">";
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
code.language-powershell span {
|
||||
display: inline !important;
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
The following contains some styles in use on the top-level pages
|
||||
(About, Community...). Bootstrap provides many responsive utilities
|
||||
|
|
|
@ -41,8 +41,8 @@ To best follow along,
|
|||
and clone the rules_protobuf repository:
|
||||
|
||||
```sh
|
||||
~$ git clone https://github.com/pubref/rules_protobuf
|
||||
~$ cd rules_protobuf
|
||||
git clone https://github.com/pubref/rules_protobuf
|
||||
cd rules_protobuf
|
||||
~/rules_protobuf$
|
||||
```
|
||||
|
||||
|
@ -89,7 +89,7 @@ Let's look at the file tree, showing only those folder having a
|
|||
`BUILD` file:
|
||||
|
||||
```diff
|
||||
$ tree -P 'BUILD|WORKSPACE' -I 'third_party|bzl' examples/
|
||||
tree -P 'BUILD|WORKSPACE' -I 'third_party|bzl' examples/
|
||||
.
|
||||
├── BUILD
|
||||
├── WORKSPACE
|
||||
|
@ -130,7 +130,7 @@ within the examples folder, and say what kind of thing it is in
|
|||
addition to its path label"*:
|
||||
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/rules_protobuf$ bazel query //examples/... --output label_kind | sort | column -t
|
||||
|
||||
cc_binary rule //examples/helloworld/cpp:client
|
||||
|
@ -174,7 +174,7 @@ named as an external repository (more on this later) and we can also
|
|||
address targets in that workspace in the same way. Here's a partial
|
||||
list:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/rules_protobuf$ bazel query @com_github_google_protobuf//... --output label_kind | sort | column -t
|
||||
|
||||
cc_binary rule @com_github_google_protobuf//:protoc
|
||||
|
@ -201,7 +201,7 @@ build all the dependent libraries, build a pristine executable binary
|
|||
from source, and call it (pass command line arguments to binary rules
|
||||
after the double-dash):
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/rules_protobuf$ bazel run @com_github_google_protobuf//:protoc -- --help
|
||||
Usage: /private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf/bazel-out/local-fastbuild/bin/external/com_github_google_protobuf/protoc [OPTION] PROTO_FILES
|
||||
Parse PROTO_FILES and generate output based on the options given:
|
||||
|
@ -322,7 +322,7 @@ via a compromised network.
|
|||
For example, we can peek at the generated BUILD file for the
|
||||
`maven_jar` guava dependency via:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/rules_protobuf$ cat $(bazel info execution_root)/external/com_google_guava_guava/jar/BUILD
|
||||
```
|
||||
|
||||
|
@ -361,7 +361,7 @@ root package of the external workspace com_github_madler_zlib.*" Bazel
|
|||
reports this reverse dependency set. We request the output in
|
||||
graphviz format and pipe this to dot to generate the figure:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/rules_protobuf$ bazel query "rdeps(deps(//examples/...), @com_github_madler_zlib//:zlib)" \
|
||||
--output graph | dot -Tpng -O
|
||||
```
|
||||
|
@ -461,7 +461,7 @@ simultaneously:
|
|||
```
|
||||
|
||||
```sh
|
||||
$ bazel build :pluriproto
|
||||
bazel build :pluriproto
|
||||
# ************************************************************
|
||||
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_github_google_protobuf/protoc \
|
||||
--plugin=protoc-gen-grpc-java=bazel-out/host/genfiles/third_party/protoc_gen_grpc_java/protoc_gen_grpc_java \
|
||||
|
@ -637,7 +637,7 @@ This demo application can be cloned at
|
|||
Here's the directory layout and relevant BUILD files we'll be using:
|
||||
|
||||
```sh
|
||||
~$ mkdir grpc_greetertimer && cd grpc_greetertimer
|
||||
mkdir grpc_greetertimer && cd grpc_greetertimer
|
||||
~/grpc_greetertimer$ mkdir -p proto/ go/ java/org/pubref/grpc/greetertimer/
|
||||
~/grpc_greetertimer$ touch WORKSPACE
|
||||
~/grpc_greetertimer$ touch proto/BUILD
|
||||
|
@ -795,7 +795,7 @@ go_binary(
|
|||
)
|
||||
```
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/grpc_greetertimer$ bazel build //go:client
|
||||
```
|
||||
|
||||
|
@ -864,7 +864,7 @@ executable jar. If these jar files have not yet been downloaded from
|
|||
maven central, they will be fetch as soon as we need them:
|
||||
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/grpc_greetertimer$ bazel build java/org/pubref/grpc/greetertimer:server
|
||||
~/grpc_greetertimer$ bazel build java/org/pubref/grpc/greetertimer:server_deploy.jar
|
||||
```
|
||||
|
@ -878,7 +878,7 @@ that can be run independently in a jvm.
|
|||
|
||||
First, we'll start a greeter server (one at a time):
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/grpc_greetertimer$ cd ~/rules_protobuf
|
||||
~/rules_protobuf$ bazel run examples/helloworld/go/server
|
||||
~/rules_protobuf$ bazel run examples/helloworld/cpp/server
|
||||
|
@ -889,7 +889,7 @@ INFO: Server started, listening on 50051
|
|||
|
||||
In a separate terminal, start the greetertimer server:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/grpc_greetertimer$ bazel build //java/org/pubref/grpc/greetertimer:server_deploy.jar
|
||||
~/grpc_greetertimer$ java -jar bazel-bin/java/org/pubref/grpc/greetertimer/server_deploy.jar
|
||||
```
|
||||
|
|
|
@ -57,7 +57,7 @@ service EchoService {
|
|||
This means the gateway, once generated by `protoc`, can now accept a HTTP request from `curl` like this:
|
||||
|
||||
```sh
|
||||
$ curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
|
||||
curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
|
||||
```
|
||||
|
||||
The whole system so far looks like this, with a single `service.proto` file generating both a gRPC server and a REST proxy:
|
||||
|
@ -77,15 +77,15 @@ if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "applicat
|
|||
To try it out, all you need is a working Go 1.6 development environment and the following simple commands:
|
||||
|
||||
```sh
|
||||
$ go get -u github.com/philips/grpc-gateway-example
|
||||
$ grpc-gateway-example serve
|
||||
go get -u github.com/philips/grpc-gateway-example
|
||||
grpc-gateway-example serve
|
||||
```
|
||||
|
||||
With the server running you can try requests on both HTTP 1.1 and gRPC interfaces:
|
||||
|
||||
```sh
|
||||
$ grpc-gateway-example echo Take a REST from REST with gRPC
|
||||
$ curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
|
||||
grpc-gateway-example echo Take a REST from REST with gRPC
|
||||
curl -X POST -k https://localhost:10000/v1/echo -d '{"value": "CoreOS is hiring!"}'
|
||||
```
|
||||
|
||||
One last bonus: because we have an Open API specification, you can browse the Open API UI running at `https://localhost:10000/swagger-ui/#!/EchoService/Echo` if you have the server above running on your laptop.
|
||||
|
|
|
@ -37,7 +37,7 @@ directory
|
|||
|
||||
Let's start by creating a new library project.
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/work$ dotnet new classlib -o MyGreeter
|
||||
The template "Class library" was created successfully.
|
||||
|
||||
|
@ -55,7 +55,7 @@ this exercise, we'll copy an example file [`examples/protos/helloworld.proto`
|
|||
](https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto)
|
||||
from the gRPC distribution.
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/work/MyGreeter$ rm Class1.cs
|
||||
~/work/MyGreeter$ wget -q https://raw.githubusercontent.com/grpc/grpc/master/examples/protos/helloworld.proto
|
||||
```
|
||||
|
@ -67,7 +67,7 @@ and use a *Save As...* command from your Web browser).
|
|||
|
||||
Next, add required NuGet packages to the project:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/work/MyGreeter$ dotnet add package Grpc
|
||||
info : PackageReference for package 'Grpc' version '1.17.0' added to file '/home/kkm/work/MyGreeter/MyGreeter.csproj'.
|
||||
~/work/MyGreeter$ dotnet add package Grpc.Tools
|
||||
|
@ -131,7 +131,7 @@ idea to always do that the very first time you compile a project!
|
|||
Note that many output lines are omitted below, as the build output is quite
|
||||
verbose.
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/work/MyGreeter$ dotnet build -v:n
|
||||
|
||||
Build started 11/9/18 5:33:44 PM.
|
||||
|
@ -173,7 +173,7 @@ accidentally placed under source control. Otherwise, they are accessible to the
|
|||
tools like the debugger. You can see other autogenerated sources in that
|
||||
directory, too:
|
||||
|
||||
```sh
|
||||
```bash
|
||||
~/work/MyGreeter$ find obj -name '*.cs'
|
||||
obj/Debug/netstandard2.0/MyGreeter.AssemblyInfo.cs
|
||||
obj/Debug/netstandard2.0/Helloworld.cs
|
||||
|
|
|
@ -78,7 +78,7 @@ service TodoService {
|
|||
CommonJS client-side code can be generated from this `.proto` definition with the following command:
|
||||
|
||||
```sh
|
||||
$ protoc echo.proto \
|
||||
protoc echo.proto \
|
||||
--js_out=import_style=commonjs:./output \
|
||||
--grpc-web_out=import_style=commonjs:./output
|
||||
```
|
||||
|
|
|
@ -172,8 +172,8 @@ final class KvService extends KvGson.KeyValueServiceImplBase {
|
|||
After implementing all the methods on the server, we now have a fully functioning gRPC Java, JSON encoding RPC system. And to show you there is nothing up my sleeve:
|
||||
|
||||
```sh
|
||||
$ ./gradlew :dependencies | grep -i proto
|
||||
$ # no proto deps!
|
||||
./gradlew :dependencies | grep -i proto
|
||||
# no proto deps!
|
||||
```
|
||||
|
||||
## Optimizing the Code
|
||||
|
@ -181,8 +181,8 @@ $ # no proto deps!
|
|||
While Gson is not as fast as Protobuf, there's no sense in not picking the low hanging fruit. Running the code we see the performance is pretty slow:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
$ time ./build/install/kvstore/bin/kvstore
|
||||
./gradlew installDist
|
||||
time ./build/install/kvstore/bin/kvstore
|
||||
|
||||
INFO: Did 215.883 RPCs/s
|
||||
```
|
||||
|
@ -213,8 +213,8 @@ That's not right! Looking at a `RetrieveRequest`, we see that the key bytes are
|
|||
Using this in our marshallers, we can see a dramatic performance difference:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
$ time ./build/install/kvstore/bin/kvstore
|
||||
./gradlew installDist
|
||||
time ./build/install/kvstore/bin/kvstore
|
||||
|
||||
INFO: Did 2,202.2 RPCs/s
|
||||
```
|
||||
|
|
|
@ -133,8 +133,8 @@ Since the code is safe and correct, let's see how it performs. For my measureme
|
|||
Ubuntu system with a 12 core processor and 32 GB of memory. Let's build and run the code:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
$ time ./build/install/kvstore/bin/kvstore
|
||||
./gradlew installDist
|
||||
time ./build/install/kvstore/bin/kvstore
|
||||
Feb 26, 2018 1:10:07 PM io.grpc.examples.KvRunner runClient
|
||||
INFO: Starting
|
||||
Feb 26, 2018 1:11:07 PM io.grpc.examples.KvRunner runClient
|
||||
|
@ -345,8 +345,8 @@ Now the code runs successfully, and doesn't run out of memory.
|
|||
Building and running the code again looks a lot better:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
$ time ./build/install/kvstore/bin/kvstore
|
||||
./gradlew installDist
|
||||
time ./build/install/kvstore/bin/kvstore
|
||||
Feb 26, 2018 2:40:47 PM io.grpc.examples.KvRunner runClient
|
||||
INFO: Starting
|
||||
Feb 26, 2018 2:41:47 PM io.grpc.examples.KvRunner runClient
|
||||
|
|
|
@ -170,8 +170,8 @@ per RPC, but a lot more are happening at the same time. Let's see if our hypoth
|
|||
Before:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
$ time ./build/install/kvstore/bin/kvstore
|
||||
./gradlew installDist
|
||||
time ./build/install/kvstore/bin/kvstore
|
||||
Apr 16, 2018 10:38:42 AM io.grpc.examples.KvRunner runClient
|
||||
INFO: Did 24.067 RPCs/s
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ Get the example code and build gRPC:
|
|||
2. From the repo folder, change to the route guide example directory:
|
||||
|
||||
```sh
|
||||
$ cd examples/cpp/route_guide
|
||||
cd examples/cpp/route_guide
|
||||
```
|
||||
3. Run `cmake`
|
||||
|
||||
```sh
|
||||
$ mkdir -p cmake/build
|
||||
$ cd cmake/build
|
||||
$ cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
|
||||
mkdir -p cmake/build
|
||||
cd cmake/build
|
||||
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
|
||||
```
|
||||
|
||||
### Defining the service
|
||||
|
@ -142,14 +142,14 @@ you want to run this yourself, make sure you've installed protoc and followed
|
|||
the gRPC code [installation instructions](https://github.com/grpc/grpc/blob/{{< param grpc_vers.core >}}/src/cpp/README.md#cmake) first):
|
||||
|
||||
```sh
|
||||
$ make route_guide.grpc.pb.o
|
||||
make route_guide.grpc.pb.o
|
||||
```
|
||||
|
||||
which actually runs:
|
||||
|
||||
```sh
|
||||
$ protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/route_guide.proto
|
||||
$ protoc -I ../../protos --cpp_out=. ../../protos/route_guide.proto
|
||||
protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../protos/route_guide.proto
|
||||
protoc -I ../../protos --cpp_out=. ../../protos/route_guide.proto
|
||||
```
|
||||
|
||||
Running this command generates the following files in your current directory:
|
||||
|
@ -502,19 +502,19 @@ independently.
|
|||
Build the client and server:
|
||||
|
||||
```sh
|
||||
$ make
|
||||
make
|
||||
```
|
||||
|
||||
Run the server:
|
||||
|
||||
```sh
|
||||
$ ./route_guide_server --db_path=path/to/route_guide_db.json
|
||||
./route_guide_server --db_path=path/to/route_guide_db.json
|
||||
```
|
||||
|
||||
From a different terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ./route_guide_client --db_path=path/to/route_guide_db.json
|
||||
./route_guide_client --db_path=path/to/route_guide_db.json
|
||||
```
|
||||
|
||||
[build and locally install gRPC from source]: {{< relref "quickstart#install-grpc" >}}
|
||||
|
|
|
@ -26,37 +26,37 @@ example:
|
|||
- Linux / macOS
|
||||
|
||||
```sh
|
||||
$ export MY_INSTALL_DIR=$HOME/.local
|
||||
export MY_INSTALL_DIR=$HOME/.local
|
||||
```
|
||||
|
||||
Ensure that the directory exists:
|
||||
|
||||
```sh
|
||||
$ mkdir -p $MY_INSTALL_DIR
|
||||
mkdir -p $MY_INSTALL_DIR
|
||||
```
|
||||
|
||||
Add the local `bin` folder to your path variable, for example:
|
||||
|
||||
```sh
|
||||
$ export PATH="$MY_INSTALL_DIR/bin:$PATH"
|
||||
export PATH="$MY_INSTALL_DIR/bin:$PATH"
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```sh
|
||||
> set MY_INSTALL_DIR=%USERPROFILE%\cmake
|
||||
```powershell
|
||||
set MY_INSTALL_DIR=%USERPROFILE%\cmake
|
||||
```
|
||||
|
||||
Ensure that the directory exists:
|
||||
|
||||
```
|
||||
> mkdir %INSTALL_DIR%
|
||||
```powershell
|
||||
mkdir %INSTALL_DIR%
|
||||
```
|
||||
|
||||
Add the local `bin` folder to your path variable, for example:
|
||||
|
||||
```sh
|
||||
> set PATH=%PATH%;$MY_INSTALL_DIR\bin
|
||||
```powershell
|
||||
set PATH=%PATH%;$MY_INSTALL_DIR\bin
|
||||
```
|
||||
|
||||
#### Install cmake
|
||||
|
@ -67,19 +67,19 @@ following these instructions if you don't have it:
|
|||
- Linux
|
||||
|
||||
```sh
|
||||
$ sudo apt install -y cmake
|
||||
sudo apt install -y cmake
|
||||
```
|
||||
|
||||
- macOS:
|
||||
|
||||
```sh
|
||||
$ brew install cmake
|
||||
brew install cmake
|
||||
```
|
||||
|
||||
- Windows:
|
||||
|
||||
```sh
|
||||
$ choco install cmake
|
||||
choco install cmake
|
||||
```
|
||||
|
||||
- For general `cmake` installation instructions, see [Installing CMake][].
|
||||
|
@ -87,7 +87,7 @@ following these instructions if you don't have it:
|
|||
Check the version of `cmake`:
|
||||
|
||||
```sh
|
||||
$ cmake --version
|
||||
cmake --version
|
||||
cmake version {{< param cmake-version >}}
|
||||
```
|
||||
|
||||
|
@ -96,9 +96,9 @@ can install a more recent version into your local installation directory as
|
|||
follows:
|
||||
|
||||
```sh
|
||||
$ wget -q -O cmake-linux.sh https://github.com/Kitware/CMake/releases/download/v{{< param cmake-version >}}/cmake-{{< param cmake-version >}}-linux-x86_64.sh
|
||||
$ sh cmake-linux.sh -- --skip-license --prefix=$MY_INSTALL_DIR
|
||||
$ rm cmake-linux.sh
|
||||
wget -q -O cmake-linux.sh https://github.com/Kitware/CMake/releases/download/v{{< param cmake-version >}}/cmake-{{< param cmake-version >}}-linux-x86_64.sh
|
||||
sh cmake-linux.sh -- --skip-license --prefix=$MY_INSTALL_DIR
|
||||
rm cmake-linux.sh
|
||||
```
|
||||
|
||||
#### Install other required tools
|
||||
|
@ -108,13 +108,13 @@ Install the basic tools required to build gRPC:
|
|||
- Linux
|
||||
|
||||
```sh
|
||||
$ sudo apt install -y build-essential autoconf libtool pkg-config
|
||||
sudo apt install -y build-essential autoconf libtool pkg-config
|
||||
```
|
||||
|
||||
- macOS:
|
||||
|
||||
```sh
|
||||
$ brew install autoconf automake libtool pkg-config
|
||||
brew install autoconf automake libtool pkg-config
|
||||
```
|
||||
|
||||
#### Clone the `grpc` repo
|
||||
|
@ -122,7 +122,7 @@ Install the basic tools required to build gRPC:
|
|||
Clone the `grpc` repo and its submodules:
|
||||
|
||||
```sh
|
||||
$ git clone --recurse-submodules -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone --recurse-submodules -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
```
|
||||
#### Build and install gRPC and Protocol Buffers
|
||||
|
||||
|
@ -135,26 +135,26 @@ The following commands build and locally install gRPC and Protocol Buffers:
|
|||
- Linux & macOS
|
||||
|
||||
```sh
|
||||
$ cd grpc
|
||||
$ mkdir -p cmake/build
|
||||
$ pushd cmake/build
|
||||
$ cmake -DgRPC_INSTALL=ON \
|
||||
cd grpc
|
||||
mkdir -p cmake/build
|
||||
pushd cmake/build
|
||||
cmake -DgRPC_INSTALL=ON \
|
||||
-DgRPC_BUILD_TESTS=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
|
||||
../..
|
||||
$ make -j 4
|
||||
$ make install
|
||||
$ popd
|
||||
make -j 4
|
||||
make install
|
||||
popd
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```sh
|
||||
> mkdir "cmake\build"
|
||||
> pushd "cmake\build"
|
||||
> cmake -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% -DgRPC_BUILD_TESTS=OFF ..\..
|
||||
> cmake --build . --config Release --target install -j 4
|
||||
> popd
|
||||
```powershell
|
||||
mkdir "cmake\build"
|
||||
pushd "cmake\build"
|
||||
cmake -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% -DgRPC_BUILD_TESTS=OFF ..\..
|
||||
cmake --build . --config Release --target install -j 4
|
||||
popd
|
||||
```
|
||||
|
||||
{{% alert title="Important" color="warning" %}}
|
||||
|
@ -178,7 +178,7 @@ the steps of the previous section.
|
|||
1. Change to the example's directory:
|
||||
|
||||
```sh
|
||||
$ cd examples/cpp/helloworld
|
||||
cd examples/cpp/helloworld
|
||||
```
|
||||
|
||||
2. Build the example using `cmake`:
|
||||
|
@ -186,20 +186,20 @@ the steps of the previous section.
|
|||
- Linux & macOS
|
||||
|
||||
```sh
|
||||
$ mkdir -p cmake/build
|
||||
$ pushd cmake/build
|
||||
$ cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
|
||||
$ make -j 4
|
||||
mkdir -p cmake/build
|
||||
pushd cmake/build
|
||||
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
|
||||
make -j 4
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```sh
|
||||
> mkdir "cmake\build"
|
||||
> pushd "cmake\build"
|
||||
> cmake -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% ..\..
|
||||
> cmake --build . --config Release -j 4
|
||||
> popd
|
||||
```powershell
|
||||
mkdir "cmake\build"
|
||||
pushd "cmake\build"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% ..\..
|
||||
cmake --build . --config Release -j 4
|
||||
popd
|
||||
```
|
||||
|
||||
{{% alert title="Note" color="info" %}}
|
||||
|
@ -216,13 +216,13 @@ Run the example from the example **build** directory
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./greeter_server
|
||||
./greeter_server
|
||||
```
|
||||
|
||||
1. From a different terminal, run the client and see the client output:
|
||||
|
||||
```sh
|
||||
$ ./greeter_client
|
||||
./greeter_client
|
||||
Greeter received: Hello world
|
||||
```
|
||||
|
||||
|
@ -291,14 +291,14 @@ From the example **build** directory `examples/cpp/helloworld/cmake/build`, run:
|
|||
|
||||
- Linux & macOS
|
||||
|
||||
```sh
|
||||
$ make -j 4
|
||||
```powershell
|
||||
make -j 4
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```sh
|
||||
> cmake --build . --config Release -j 4
|
||||
```powershell
|
||||
cmake --build . --config Release -j 4
|
||||
```
|
||||
|
||||
This regenerates `helloworld.pb.{h,cc}` and `helloworld.grpc.pb.{h,cc}`, which
|
||||
|
@ -389,24 +389,24 @@ from the example **build** directory `examples/cpp/helloworld/cmake/build`:
|
|||
|
||||
- Linux & macOS
|
||||
```sh
|
||||
$ make -j 4
|
||||
make -j 4
|
||||
```
|
||||
|
||||
- Windows
|
||||
```sh
|
||||
> cmake --build . --config Release -j 4
|
||||
```powershell
|
||||
cmake --build . --config Release -j 4
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./greeter_server
|
||||
./greeter_server
|
||||
```
|
||||
|
||||
3. On a different terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ./greeter_client
|
||||
./greeter_client
|
||||
```
|
||||
|
||||
You'll see the following output:
|
||||
|
|
|
@ -33,13 +33,13 @@ To download the example, clone the `grpc-dart` repository by running the followi
|
|||
command:
|
||||
|
||||
```sh
|
||||
$ git clone --depth 1 https://github.com/grpc/grpc-dart
|
||||
git clone --depth 1 https://github.com/grpc/grpc-dart
|
||||
```
|
||||
|
||||
Then change your current directory to `grpc-dart/example/route_guide`:
|
||||
|
||||
```sh
|
||||
$ cd grpc-dart/example/route_guide
|
||||
cd grpc-dart/example/route_guide
|
||||
```
|
||||
|
||||
You should have already installed the tools needed to generate client and server
|
||||
|
@ -507,25 +507,25 @@ write in any order — the streams operate completely independently.
|
|||
Work from the example directory:
|
||||
|
||||
```sh
|
||||
$ cd example/route_guide
|
||||
cd example/route_guide
|
||||
```
|
||||
|
||||
Get packages:
|
||||
|
||||
```sh
|
||||
$ dart pub get
|
||||
dart pub get
|
||||
```
|
||||
|
||||
Run the server:
|
||||
|
||||
```sh
|
||||
$ dart bin/server.dart
|
||||
dart bin/server.dart
|
||||
```
|
||||
|
||||
From a different terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ dart bin/client.dart
|
||||
dart bin/client.dart
|
||||
```
|
||||
|
||||
### Reporting issues
|
||||
|
|
|
@ -22,13 +22,13 @@ spelling: cSpell:ignore Iprotos
|
|||
the following command:
|
||||
|
||||
```sh
|
||||
$ dart pub global activate protoc_plugin
|
||||
dart pub global activate protoc_plugin
|
||||
```
|
||||
|
||||
2. Update your `PATH` so that the `protoc` compiler can find the plugin:
|
||||
|
||||
```sh
|
||||
$ export PATH="$PATH:$HOME/.pub-cache/bin"
|
||||
export PATH="$PATH:$HOME/.pub-cache/bin"
|
||||
```
|
||||
|
||||
{{% alert title="Note" color="info" %}}
|
||||
|
@ -43,13 +43,13 @@ The example code is part of the [grpc-dart][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/grpc/grpc-dart
|
||||
git clone https://github.com/grpc/grpc-dart
|
||||
```
|
||||
|
||||
2. Change to the quick start example directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-dart/example/helloworld
|
||||
cd grpc-dart/example/helloworld
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -59,19 +59,19 @@ From the `example/helloworld` directory:
|
|||
1. Download package dependencies:
|
||||
|
||||
```sh
|
||||
$ dart pub get
|
||||
dart pub get
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ dart bin/server.dart
|
||||
dart bin/server.dart
|
||||
```
|
||||
|
||||
3. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ dart bin/client.dart
|
||||
dart bin/client.dart
|
||||
Greeter client received: Hello, world!
|
||||
```
|
||||
|
||||
|
@ -138,7 +138,7 @@ Before you can use the new service method, you need to recompile the updated
|
|||
proto file. From the `example/helloworld` directory, run the following command:
|
||||
|
||||
```sh
|
||||
$ protoc --dart_out=grpc:lib/src/generated -Iprotos protos/helloworld.proto
|
||||
protoc --dart_out=grpc:lib/src/generated -Iprotos protos/helloworld.proto
|
||||
```
|
||||
|
||||
You'll find the regenerated request and response classes, and client and server
|
||||
|
@ -200,14 +200,14 @@ from the `example/helloworld` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ dart bin/server.dart
|
||||
dart bin/server.dart
|
||||
```
|
||||
|
||||
2. From another terminal, run the client. This time, add a name as a command-line
|
||||
argument:
|
||||
|
||||
```sh
|
||||
$ dart bin/client.dart Alice
|
||||
dart bin/client.dart Alice
|
||||
```
|
||||
|
||||
You'll see the following output:
|
||||
|
|
|
@ -40,13 +40,13 @@ The example code is part of the [grpc-go][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.go >}} --depth 1 https://github.com/grpc/grpc-go
|
||||
git clone -b {{< param grpc_vers.go >}} --depth 1 https://github.com/grpc/grpc-go
|
||||
```
|
||||
|
||||
2. Change to the example directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-go/examples/route_guide
|
||||
cd grpc-go/examples/route_guide
|
||||
```
|
||||
|
||||
### Defining the service
|
||||
|
@ -142,7 +142,7 @@ a special gRPC Go plugin. This is similar to what we did in the [Quick start][].
|
|||
From the `examples/route_guide` directory, run the following command:
|
||||
|
||||
```sh
|
||||
$ protoc --go_out=. --go_opt=paths=source_relative \
|
||||
protoc --go_out=. --go_opt=paths=source_relative \
|
||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
||||
routeguide/route_guide.proto
|
||||
```
|
||||
|
@ -566,13 +566,13 @@ Execute the following commands from the `examples/route_guide` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ go run server/server.go
|
||||
go run server/server.go
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ go run client/client.go
|
||||
go run client/client.go
|
||||
```
|
||||
|
||||
You'll see output like this:
|
||||
|
|
|
@ -21,14 +21,14 @@ spelling: cSpell:ignore Fatalf GOPATH
|
|||
1. Install the protocol compiler plugins for Go using the following commands:
|
||||
|
||||
```sh
|
||||
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
```
|
||||
|
||||
2. Update your `PATH` so that the `protoc` compiler can find the plugins:
|
||||
|
||||
```sh
|
||||
$ export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
```
|
||||
|
||||
### Get the example code
|
||||
|
@ -39,13 +39,13 @@ The example code is part of the [grpc-go][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.go >}} --depth 1 https://github.com/grpc/grpc-go
|
||||
git clone -b {{< param grpc_vers.go >}} --depth 1 https://github.com/grpc/grpc-go
|
||||
```
|
||||
|
||||
2. Change to the quick start example directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-go/examples/helloworld
|
||||
cd grpc-go/examples/helloworld
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -55,14 +55,14 @@ From the `examples/helloworld` directory:
|
|||
1. Compile and execute the server code:
|
||||
|
||||
```sh
|
||||
$ go run greeter_server/main.go
|
||||
go run greeter_server/main.go
|
||||
```
|
||||
|
||||
2. From a different terminal, compile and execute the client code to see the
|
||||
client output:
|
||||
|
||||
```sh
|
||||
$ go run greeter_client/main.go
|
||||
go run greeter_client/main.go
|
||||
Greeting: Hello world
|
||||
```
|
||||
|
||||
|
@ -129,7 +129,7 @@ Before you can use the new service method, you need to recompile the updated
|
|||
While still in the `examples/helloworld` directory, run the following command:
|
||||
|
||||
```sh
|
||||
$ protoc --go_out=. --go_opt=paths=source_relative \
|
||||
protoc --go_out=. --go_opt=paths=source_relative \
|
||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
||||
helloworld/helloworld.proto
|
||||
```
|
||||
|
@ -178,14 +178,14 @@ from the `examples/helloworld` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ go run greeter_server/main.go
|
||||
go run greeter_server/main.go
|
||||
```
|
||||
|
||||
2. From another terminal, run the client. This time, add a name as a
|
||||
command-line argument:
|
||||
|
||||
```sh
|
||||
$ go run greeter_client/main.go --name=Alice
|
||||
go run greeter_client/main.go --name=Alice
|
||||
```
|
||||
|
||||
You'll see the following output:
|
||||
|
|
|
@ -35,13 +35,13 @@ To download the example, clone the latest release in `grpc-java` repository by
|
|||
running the following command:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.java >}} --depth 1 https://github.com/grpc/grpc-java
|
||||
git clone -b {{< param grpc_vers.java >}} --depth 1 https://github.com/grpc/grpc-java
|
||||
```
|
||||
|
||||
Then change your current directory to `grpc-java/examples`:
|
||||
|
||||
```sh
|
||||
$ cd grpc-java/examples
|
||||
cd grpc-java/examples
|
||||
```
|
||||
|
||||
### Defining the service
|
||||
|
|
|
@ -316,6 +316,6 @@ If you wish to invoke the protobuf plugin for gRPC Java directly,
|
|||
the command-line syntax is as follows:
|
||||
|
||||
```sh
|
||||
$ protoc --plugin=protoc-gen-grpc-java \
|
||||
protoc --plugin=protoc-gen-grpc-java \
|
||||
--grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
|
||||
```
|
||||
|
|
|
@ -16,13 +16,13 @@ The example code is part of the [grpc-java][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.java >}} --depth 1 https://github.com/grpc/grpc-java
|
||||
git clone -b {{< param grpc_vers.java >}} --depth 1 https://github.com/grpc/grpc-java
|
||||
```
|
||||
|
||||
2. Change to the examples directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-java/examples
|
||||
cd grpc-java/examples
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -32,20 +32,20 @@ From the `examples` directory:
|
|||
1. Compile the client and server
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./build/install/examples/bin/hello-world-server
|
||||
./build/install/examples/bin/hello-world-server
|
||||
INFO: Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ./build/install/examples/bin/hello-world-client
|
||||
./build/install/examples/bin/hello-world-client
|
||||
INFO: Will try to greet world ...
|
||||
INFO: Greeting: Hello world
|
||||
```
|
||||
|
@ -206,20 +206,20 @@ from the `examples` directory:
|
|||
1. Compile the client and server:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./build/install/examples/bin/hello-world-server
|
||||
./build/install/examples/bin/hello-world-server
|
||||
INFO: Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ./build/install/examples/bin/hello-world-client
|
||||
./build/install/examples/bin/hello-world-client
|
||||
INFO: Will try to greet world ...
|
||||
INFO: Greeting: Hello world
|
||||
INFO: Greeting: Hello again world
|
||||
|
|
|
@ -34,13 +34,13 @@ The example code is part of the [grpc-kotlin][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone --depth 1 https://github.com/grpc/grpc-kotlin
|
||||
git clone --depth 1 https://github.com/grpc/grpc-kotlin
|
||||
```
|
||||
|
||||
2. Change to the examples directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-kotlin/examples
|
||||
cd grpc-kotlin/examples
|
||||
```
|
||||
|
||||
### Defining the service
|
||||
|
@ -474,20 +474,20 @@ Run the following commands from the `grpc-kotlin/examples` directory:
|
|||
1. Compile the client and server
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./server/build/install/server/bin/route-guide-server
|
||||
./server/build/install/server/bin/route-guide-server
|
||||
Server started, listening on 8980
|
||||
```
|
||||
|
||||
3. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ./client/build/install/client/bin/route-guide-client
|
||||
./client/build/install/client/bin/route-guide-client
|
||||
```
|
||||
|
||||
You'll see client output like this:
|
||||
|
|
|
@ -18,13 +18,13 @@ The example code is part of the [grpc-kotlin][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone --depth 1 https://github.com/grpc/grpc-kotlin
|
||||
git clone --depth 1 https://github.com/grpc/grpc-kotlin
|
||||
```
|
||||
|
||||
2. Change to the examples directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-kotlin/examples
|
||||
cd grpc-kotlin/examples
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -34,20 +34,20 @@ From the `examples` directory:
|
|||
1. Compile the client and server
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./server/build/install/server/bin/hello-world-server
|
||||
./server/build/install/server/bin/hello-world-server
|
||||
Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ./client/build/install/client/bin/hello-world-client
|
||||
./client/build/install/client/bin/hello-world-client
|
||||
Received: Hello world
|
||||
```
|
||||
|
||||
|
@ -169,13 +169,13 @@ from the `examples` directory:
|
|||
1. Compile the client and server:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./server/build/install/server/bin/hello-world-server
|
||||
./server/build/install/server/bin/hello-world-server
|
||||
Server started, listening on 50051
|
||||
```
|
||||
|
||||
|
@ -183,7 +183,7 @@ from the `examples` directory:
|
|||
command-line argument:
|
||||
|
||||
```sh
|
||||
$ ./client/build/install/client/bin/hello-world-client Alice
|
||||
./client/build/install/client/bin/hello-world-client Alice
|
||||
Received: Hello Alice
|
||||
Received: Hello again Alice
|
||||
```
|
||||
|
|
|
@ -45,14 +45,14 @@ To download the example, clone the `grpc` repository by running the following
|
|||
command:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.node >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc-node
|
||||
$ cd grpc
|
||||
git clone -b {{< param grpc_vers.node >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc-node
|
||||
cd grpc
|
||||
```
|
||||
|
||||
Then change your current directory to `examples`:
|
||||
|
||||
```sh
|
||||
$ cd examples
|
||||
cd examples
|
||||
```
|
||||
|
||||
You also should have the relevant tools installed to generate the server and
|
||||
|
@ -495,17 +495,17 @@ independently.
|
|||
Build the client and server:
|
||||
|
||||
```sh
|
||||
$ npm install
|
||||
npm install
|
||||
```
|
||||
|
||||
Run the server:
|
||||
|
||||
```sh
|
||||
$ node ./routeguide/dynamic_codegen/route_guide_server.js --db_path=./routeguide/dynamic_codegen/route_guide_db.json
|
||||
node ./routeguide/dynamic_codegen/route_guide_server.js --db_path=./routeguide/dynamic_codegen/route_guide_db.json
|
||||
```
|
||||
|
||||
From a different terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ node ./routeguide/dynamic_codegen/route_guide_client.js --db_path=./routeguide/dynamic_codegen/route_guide_db.json
|
||||
node ./routeguide/dynamic_codegen/route_guide_client.js --db_path=./routeguide/dynamic_codegen/route_guide_db.json
|
||||
```
|
||||
|
|
|
@ -18,13 +18,13 @@ and other tutorials):
|
|||
|
||||
```sh
|
||||
# Clone the repository to get the example code
|
||||
$ git clone -b {{< param grpc_vers.node >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc-node
|
||||
git clone -b {{< param grpc_vers.node >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc-node
|
||||
# Navigate to the node example
|
||||
$ cd grpc-node/examples
|
||||
cd grpc-node/examples
|
||||
# Install the example's dependencies
|
||||
$ npm install
|
||||
npm install
|
||||
# Navigate to the dynamic codegen "hello, world" Node example:
|
||||
$ cd helloworld/dynamic_codegen
|
||||
cd helloworld/dynamic_codegen
|
||||
```
|
||||
|
||||
### Run a gRPC application
|
||||
|
@ -34,13 +34,13 @@ From the `examples/helloworld/dynamic_codegen` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ node greeter_server.js
|
||||
node greeter_server.js
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ node greeter_client.js
|
||||
node greeter_client.js
|
||||
```
|
||||
|
||||
Congratulations! You've just run a client-server application with gRPC.
|
||||
|
@ -153,13 +153,13 @@ Just like we did before, from the `examples/helloworld/dynamic_codegen` director
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ node greeter_server.js
|
||||
node greeter_server.js
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ node greeter_client.js
|
||||
node greeter_client.js
|
||||
```
|
||||
|
||||
### What's next
|
||||
|
|
|
@ -34,15 +34,15 @@ To download the example, clone the `grpc` repository by running the following
|
|||
commands:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
$ cd grpc
|
||||
$ git submodule update --init
|
||||
git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
cd grpc
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
Then change your current directory to `examples/objective-c/route_guide`:
|
||||
|
||||
```sh
|
||||
$ cd examples/objective-c/route_guide
|
||||
cd examples/objective-c/route_guide
|
||||
```
|
||||
|
||||
Our example is a simple route mapping application that lets clients get
|
||||
|
@ -61,16 +61,16 @@ To try the sample app, we need a gRPC server running locally. Let's compile and
|
|||
run, for example, the C++ server in this repository:
|
||||
|
||||
```sh
|
||||
$ pushd ../../cpp/route_guide
|
||||
$ make
|
||||
$ ./route_guide_server &
|
||||
$ popd
|
||||
pushd ../../cpp/route_guide
|
||||
make
|
||||
./route_guide_server &
|
||||
popd
|
||||
```
|
||||
|
||||
Now have Cocoapods generate and install the client library for our .proto files:
|
||||
|
||||
```sh
|
||||
$ pod install
|
||||
pod install
|
||||
```
|
||||
|
||||
(This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods
|
||||
|
@ -186,13 +186,13 @@ describes how to compile the generated files. You just need to run in this
|
|||
directory (`examples/objective-c/route_guide`):
|
||||
|
||||
```sh
|
||||
$ pod install
|
||||
pod install
|
||||
```
|
||||
|
||||
which, before installing the generated library in the XCode project of this sample, runs:
|
||||
|
||||
```sh
|
||||
$ protoc -I ../../protos --objc_out=Pods/RouteGuide --objcgrpc_out=Pods/RouteGuide ../../protos/route_guide.proto
|
||||
protoc -I ../../protos --objc_out=Pods/RouteGuide --objcgrpc_out=Pods/RouteGuide ../../protos/route_guide.proto
|
||||
```
|
||||
|
||||
Running this command generates the following files under `Pods/RouteGuide/`:
|
||||
|
|
|
@ -25,15 +25,15 @@ For the example source, see [gprc/examples/objective-c/auth_sample][]. To
|
|||
download the example, clone this repository by running the following commands:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
$ cd grpc
|
||||
$ git submodule update --init
|
||||
git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
cd grpc
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
Then change your current directory to `examples/objective-c/auth_sample`:
|
||||
|
||||
```sh
|
||||
$ cd examples/objective-c/auth_sample
|
||||
cd examples/objective-c/auth_sample
|
||||
```
|
||||
|
||||
Our example is a simple application with two views. The first view lets a user
|
||||
|
@ -65,7 +65,7 @@ To try the sample app, first have CocoaPods generate and install the client libr
|
|||
files:
|
||||
|
||||
```sh
|
||||
$ pod install
|
||||
pod install
|
||||
```
|
||||
|
||||
(This might have to compile OpenSSL, which takes around 15 minutes if CocoaPods
|
||||
|
|
|
@ -18,7 +18,7 @@ weight: 10
|
|||
Check the status and version of CocoaPods on your system:
|
||||
|
||||
```sh
|
||||
$ pod --version
|
||||
pod --version
|
||||
```
|
||||
|
||||
If CocoaPods is not installed, follow the [CocoaPods install
|
||||
|
@ -32,7 +32,7 @@ weight: 10
|
|||
Make sure the command line developer tools are installed:
|
||||
|
||||
```sh
|
||||
$ xcode-select --install
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
- [Homebrew](https://brew.sh/)
|
||||
|
@ -40,7 +40,7 @@ weight: 10
|
|||
- `autoconf`, `automake`, `libtool`, `pkg-config`
|
||||
|
||||
```sh
|
||||
$ brew install autoconf automake libtool pkg-config
|
||||
brew install autoconf automake libtool pkg-config
|
||||
```
|
||||
|
||||
### Download the example
|
||||
|
@ -50,22 +50,22 @@ Quickstart. Copy the source code from GitHub
|
|||
[repository](https://github.com/grpc/grpc):
|
||||
|
||||
```sh
|
||||
$ git clone --recursive -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone --recursive -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
```
|
||||
|
||||
### Install gRPC plugins and libraries
|
||||
|
||||
```sh
|
||||
$ cd grpc
|
||||
$ make
|
||||
$ [sudo] make install
|
||||
cd grpc
|
||||
make
|
||||
[sudo] make install
|
||||
```
|
||||
|
||||
### Install protoc compiler
|
||||
|
||||
```sh
|
||||
$ brew tap grpc/grpc
|
||||
$ brew install protobuf
|
||||
brew tap grpc/grpc
|
||||
brew install protobuf
|
||||
```
|
||||
|
||||
### Run the server:
|
||||
|
@ -75,9 +75,9 @@ Objective-C API supports creating gRPC clients but not gRPC servers. Therefore
|
|||
instead we build and run the C++ server in the same repository:
|
||||
|
||||
```sh
|
||||
$ cd examples/cpp/helloworld
|
||||
$ make
|
||||
$ ./greeter_server &
|
||||
cd examples/cpp/helloworld
|
||||
make
|
||||
./greeter_server &
|
||||
```
|
||||
|
||||
### Run the client:
|
||||
|
@ -88,8 +88,8 @@ Have CocoaPods generate and install the client library from our .proto files, as
|
|||
well as installing several dependencies:
|
||||
|
||||
```sh
|
||||
$ cd ../../objective-c/helloworld
|
||||
$ pod install
|
||||
cd ../../objective-c/helloworld
|
||||
pod install
|
||||
```
|
||||
|
||||
(This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods
|
||||
|
@ -100,7 +100,7 @@ doesn't have it yet on your computer's cache.)
|
|||
Open the Xcode workspace created by CocoaPods:
|
||||
|
||||
```sh
|
||||
$ open HelloWorld.xcworkspace
|
||||
open HelloWorld.xcworkspace
|
||||
```
|
||||
|
||||
This will open the app project with Xcode. Run the app in an iOS simulator
|
||||
|
@ -229,32 +229,32 @@ int main(int argc, char * argv[]) {
|
|||
|
||||
First terminate the server process already running in the background:
|
||||
```sh
|
||||
$ pkill greeter_server
|
||||
pkill greeter_server
|
||||
```
|
||||
|
||||
Then in directory `examples/cpp/helloworld`, build and run the updated server
|
||||
with the following commands:
|
||||
|
||||
```sh
|
||||
$ make
|
||||
$ ./greeter_server &
|
||||
make
|
||||
./greeter_server &
|
||||
```
|
||||
|
||||
Change directory to `examples/objective-c/helloworld`, then clean up and
|
||||
reinstall Pods for the client app with the following commands:
|
||||
|
||||
```sh
|
||||
$ rm -Rf Pods
|
||||
$ rm Podfile.lock
|
||||
$ rm -Rf HelloWorld.xcworkspace
|
||||
$ pod install
|
||||
rm -Rf Pods
|
||||
rm Podfile.lock
|
||||
rm -Rf HelloWorld.xcworkspace
|
||||
pod install
|
||||
```
|
||||
|
||||
This regenerates files in `Pods/HelloWorld` based on the new proto file we wrote
|
||||
above. Open the client Xcode project in Xcode:
|
||||
|
||||
```sh
|
||||
$ open HelloWorld.xcworkspace
|
||||
open HelloWorld.xcworkspace
|
||||
```
|
||||
|
||||
and run the client app. If you look at the console messages, You'll see two RPC calls,
|
||||
|
@ -267,8 +267,8 @@ When installing CocoaPods, error `activesupport requires Ruby version >= 2.2.2`
|
|||
: Install an older version of `activesupport`, then install CocoaPods:
|
||||
|
||||
```sh
|
||||
$ [sudo] gem install activesupport -v 4.2.6
|
||||
$ [sudo] gem install cocoapods
|
||||
[sudo] gem install activesupport -v 4.2.6
|
||||
[sudo] gem install cocoapods
|
||||
```
|
||||
|
||||
When installing dependencies with CocoaPods, error `Unable to find a specification for !ProtoCompiler-gRPCPlugin`
|
||||
|
|
|
@ -33,25 +33,25 @@ To download the example, clone the `grpc` repository and its submodules by runni
|
|||
command:
|
||||
|
||||
```sh
|
||||
$ git clone --recurse-submodules -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone --recurse-submodules -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
```
|
||||
|
||||
You need the `grpc-php-plugin` to help you compile `.proto` files. Build it from source as follows:
|
||||
|
||||
```sh
|
||||
$ cd grpc
|
||||
$ mkdir -p cmake/build
|
||||
$ pushd cmake/build
|
||||
$ cmake ../..
|
||||
$ make protoc grpc_php_plugin
|
||||
$ popd
|
||||
cd grpc
|
||||
mkdir -p cmake/build
|
||||
pushd cmake/build
|
||||
cmake ../..
|
||||
make protoc grpc_php_plugin
|
||||
popd
|
||||
```
|
||||
|
||||
Then change to route guide directory and compile the example's `.proto` files:
|
||||
|
||||
```sh
|
||||
$ cd examples/php/route_guide
|
||||
$ ./route_guide_proto_gen.sh
|
||||
cd examples/php/route_guide
|
||||
./route_guide_proto_gen.sh
|
||||
```
|
||||
|
||||
Our example is a simple route mapping application that lets clients get
|
||||
|
@ -70,16 +70,16 @@ To try the sample app, we need a gRPC server running locally. Let's compile and
|
|||
run, for example, the Node.js server in this repository:
|
||||
|
||||
```sh
|
||||
$ cd ../../node
|
||||
$ npm install
|
||||
$ cd dynamic_codegen/route_guide
|
||||
$ nodejs ./route_guide_server.js --db_path=route_guide_db.json
|
||||
cd ../../node
|
||||
npm install
|
||||
cd dynamic_codegen/route_guide
|
||||
nodejs ./route_guide_server.js --db_path=route_guide_db.json
|
||||
```
|
||||
|
||||
Run the PHP client (in a different terminal):
|
||||
|
||||
```sh
|
||||
$ ./run_route_guide_client.sh
|
||||
./run_route_guide_client.sh
|
||||
```
|
||||
|
||||
The next sections guide you step-by-step through how this proto service is
|
||||
|
@ -174,14 +174,14 @@ The PHP client stub implementation of the proto files can be generated by the
|
|||
gRPC PHP Protoc Plugin. To compile the plugin:
|
||||
|
||||
```sh
|
||||
$ make grpc_php_plugin
|
||||
make grpc_php_plugin
|
||||
```
|
||||
|
||||
To generate the client stub implementation .php file:
|
||||
|
||||
```sh
|
||||
$ cd grpc
|
||||
$ protoc --proto_path=examples/protos \
|
||||
cd grpc
|
||||
protoc --proto_path=examples/protos \
|
||||
--php_out=examples/php/route_guide \
|
||||
--grpc_out=examples/php/route_guide \
|
||||
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \
|
||||
|
@ -192,7 +192,7 @@ or running the helper script under the `grpc/example/php/route_guide` directory
|
|||
grpc-php-plugin by source:
|
||||
|
||||
```sh
|
||||
$ ./route_guide_proto_gen.sh
|
||||
./route_guide_proto_gen.sh
|
||||
```
|
||||
|
||||
A number of files will be generated in the `examples/php/route_guide` directory.
|
||||
|
|
|
@ -23,20 +23,20 @@ The example code is part of the [grpc][] repo.
|
|||
1. Clone the [grpc][] repo and its submodules:
|
||||
|
||||
```sh
|
||||
$ git clone --recurse-submodules -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone --recurse-submodules -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
```
|
||||
|
||||
2. Change to the quick start example directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc/examples/php
|
||||
cd grpc/examples/php
|
||||
```
|
||||
|
||||
3. Install the `grpc` composer package:
|
||||
|
||||
```sh
|
||||
$ ./greeter_proto_gen.sh
|
||||
$ composer install
|
||||
./greeter_proto_gen.sh
|
||||
composer install
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -47,7 +47,7 @@ The example code is part of the [grpc][] repo.
|
|||
2. From the `examples/php` directory, run the PHP client:
|
||||
|
||||
```sh
|
||||
$ ./run_greeter_client.sh
|
||||
./run_greeter_client.sh
|
||||
```
|
||||
|
||||
Congratulations! You've just run a client-server application with gRPC.
|
||||
|
@ -113,7 +113,7 @@ Next we need to update the gRPC code used by our application to use the new
|
|||
service definition. From the `grpc` root directory:
|
||||
|
||||
```sh
|
||||
$ protoc --proto_path=examples/protos \
|
||||
protoc --proto_path=examples/protos \
|
||||
--php_out=examples/php \
|
||||
--grpc_out=examples/php \
|
||||
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \
|
||||
|
@ -124,7 +124,7 @@ or running the helper script under the `grpc/example/php` directory if you build
|
|||
grpc-php-plugin by source:
|
||||
|
||||
```sh
|
||||
$ ./greeter_proto_gen.sh
|
||||
./greeter_proto_gen.sh
|
||||
```
|
||||
|
||||
This regenerates the protobuf files, which contain our generated client classes,
|
||||
|
@ -180,14 +180,14 @@ Just like we did before, from the `grpc-node/examples/helloworld/dynamic_codegen
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ node greeter_server.js
|
||||
node greeter_server.js
|
||||
```
|
||||
|
||||
2. From another terminal, from the `examples/php` directory,
|
||||
run the client:
|
||||
|
||||
```sh
|
||||
$ ./run_greeter_client.sh
|
||||
./run_greeter_client.sh
|
||||
```
|
||||
|
||||
### What's next
|
||||
|
|
|
@ -33,13 +33,13 @@ To download the example, clone the `grpc` repository by running the following
|
|||
command:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
```
|
||||
|
||||
Then change your current directory to `examples/python/route_guide` in the repository:
|
||||
|
||||
```sh
|
||||
$ cd grpc/examples/python/route_guide
|
||||
cd grpc/examples/python/route_guide
|
||||
```
|
||||
|
||||
You also should have the relevant tools installed to generate the server and
|
||||
|
@ -139,13 +139,13 @@ service definition.
|
|||
First, install the grpcio-tools package:
|
||||
|
||||
```sh
|
||||
$ pip install grpcio-tools
|
||||
pip install grpcio-tools
|
||||
```
|
||||
|
||||
Use the following command to generate the Python code:
|
||||
|
||||
```sh
|
||||
$ python -m grpc_tools.protoc -I../../protos --python_out=. --pyi_out=. --grpc_python_out=. ../../protos/route_guide.proto
|
||||
python -m grpc_tools.protoc -I../../protos --python_out=. --pyi_out=. --grpc_python_out=. ../../protos/route_guide.proto
|
||||
```
|
||||
|
||||
Note that as we've already provided a version of the generated code in the
|
||||
|
@ -173,7 +173,7 @@ To generate gRPC client interfaces with a custom package path, you can use the `
|
|||
Here's an example command to generate the gRPC client interfaces with a custom package path:
|
||||
|
||||
```sh
|
||||
$ python -m grpc_tools.protoc -Igrpc/example/custom/path=../../protos \
|
||||
python -m grpc_tools.protoc -Igrpc/example/custom/path=../../protos \
|
||||
--python_out=. --grpc_python_out=. \
|
||||
../../protos/route_guide.proto
|
||||
```
|
||||
|
@ -414,11 +414,11 @@ for received_route_note in stub.RouteChat(sent_route_note_iterator):
|
|||
Run the server:
|
||||
|
||||
```sh
|
||||
$ python route_guide_server.py
|
||||
python route_guide_server.py
|
||||
```
|
||||
|
||||
From a different terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ python route_guide_client.py
|
||||
python route_guide_client.py
|
||||
```
|
||||
|
|
|
@ -13,17 +13,17 @@ weight: 10
|
|||
If necessary, upgrade your version of `pip`:
|
||||
|
||||
```sh
|
||||
$ python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade pip
|
||||
```
|
||||
|
||||
If you cannot upgrade `pip` due to a system-owned installation, you can
|
||||
run the example in a virtualenv:
|
||||
|
||||
```sh
|
||||
$ python -m pip install virtualenv
|
||||
$ virtualenv venv
|
||||
$ source venv/bin/activate
|
||||
$ python -m pip install --upgrade pip
|
||||
python -m pip install virtualenv
|
||||
virtualenv venv
|
||||
source venv/bin/activate
|
||||
python -m pip install --upgrade pip
|
||||
```
|
||||
|
||||
#### gRPC
|
||||
|
@ -31,13 +31,13 @@ $ python -m pip install --upgrade pip
|
|||
Install gRPC:
|
||||
|
||||
```sh
|
||||
$ python -m pip install grpcio
|
||||
python -m pip install grpcio
|
||||
```
|
||||
|
||||
Or, to install it system wide:
|
||||
|
||||
```sh
|
||||
$ sudo python -m pip install grpcio
|
||||
sudo python -m pip install grpcio
|
||||
```
|
||||
|
||||
#### gRPC tools
|
||||
|
@ -53,7 +53,7 @@ tutorials and your own projects.
|
|||
To install gRPC tools, run:
|
||||
|
||||
```sh
|
||||
$ python -m pip install grpcio-tools
|
||||
python -m pip install grpcio-tools
|
||||
```
|
||||
|
||||
### Download the example
|
||||
|
@ -65,9 +65,9 @@ and other tutorials):
|
|||
|
||||
```sh
|
||||
# Clone the repository to get the example code:
|
||||
$ git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
# Navigate to the "hello, world" Python example:
|
||||
$ cd grpc/examples/python/helloworld
|
||||
cd grpc/examples/python/helloworld
|
||||
```
|
||||
|
||||
### Run a gRPC application
|
||||
|
@ -77,13 +77,13 @@ From the `examples/python/helloworld` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ python greeter_server.py
|
||||
python greeter_server.py
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ python greeter_client.py
|
||||
python greeter_client.py
|
||||
```
|
||||
|
||||
Congratulations! You've just run a client-server application with gRPC.
|
||||
|
@ -151,7 +151,7 @@ service definition.
|
|||
From the `examples/python/helloworld` directory, run:
|
||||
|
||||
```sh
|
||||
$ python -m grpc_tools.protoc -I../../protos --python_out=. --pyi_out=. --grpc_python_out=. ../../protos/helloworld.proto
|
||||
python -m grpc_tools.protoc -I../../protos --python_out=. --pyi_out=. --grpc_python_out=. ../../protos/helloworld.proto
|
||||
```
|
||||
|
||||
This regenerates `helloworld_pb2.py` which contains our generated request and
|
||||
|
@ -200,13 +200,13 @@ Just like we did before, from the `examples/python/helloworld` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ python greeter_server.py
|
||||
python greeter_server.py
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ python greeter_client.py
|
||||
python greeter_client.py
|
||||
```
|
||||
|
||||
### What's next
|
||||
|
|
|
@ -32,14 +32,14 @@ To download the example, clone the `grpc` repository by running the following
|
|||
command:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
$ cd grpc
|
||||
git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
cd grpc
|
||||
```
|
||||
|
||||
Then change your current directory to `examples/ruby/route_guide`:
|
||||
|
||||
```sh
|
||||
$ cd examples/ruby/route_guide
|
||||
cd examples/ruby/route_guide
|
||||
```
|
||||
|
||||
You also should have the relevant tools installed to generate the server and
|
||||
|
@ -143,7 +143,7 @@ If you want to run this yourself, make sure you have installed
|
|||
Once that's done, the following command can be used to generate the ruby code.
|
||||
|
||||
```sh
|
||||
$ grpc_tools_ruby_protoc -I ../../protos --ruby_out=../lib --grpc_out=../lib ../../protos/route_guide.proto
|
||||
grpc_tools_ruby_protoc -I ../../protos --ruby_out=../lib --grpc_out=../lib ../../protos/route_guide.proto
|
||||
```
|
||||
|
||||
Running this command regenerates the following files in the lib directory:
|
||||
|
@ -388,19 +388,19 @@ streams operate completely independently.
|
|||
Work from the example directory:
|
||||
|
||||
```sh
|
||||
$ cd examples/ruby
|
||||
cd examples/ruby
|
||||
```
|
||||
|
||||
Build the client and server:
|
||||
|
||||
```sh
|
||||
$ gem install bundler && bundle install
|
||||
gem install bundler && bundle install
|
||||
```
|
||||
|
||||
Run the server:
|
||||
|
||||
```sh
|
||||
$ bundle exec route_guide/route_guide_server.rb ../python/route_guide/route_guide_db.json
|
||||
bundle exec route_guide/route_guide_server.rb ../python/route_guide/route_guide_db.json
|
||||
```
|
||||
|
||||
{{% alert title="Note" color="info" %}}
|
||||
|
@ -410,5 +410,5 @@ The `route_guide_db.json` file is actually language-agnostic, it happens to be l
|
|||
From a different terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ bundle exec route_guide/route_guide_client.rb ../python/route_guide/route_guide_db.json
|
||||
bundle exec route_guide/route_guide_client.rb ../python/route_guide/route_guide_db.json
|
||||
```
|
||||
|
|
|
@ -13,7 +13,7 @@ weight: 10
|
|||
To install gRPC, run the following command:
|
||||
|
||||
```sh
|
||||
$ gem install grpc
|
||||
gem install grpc
|
||||
```
|
||||
|
||||
#### gRPC tools
|
||||
|
@ -29,7 +29,7 @@ tutorials and your own projects.
|
|||
To install gRPC tools, run the following command:
|
||||
|
||||
```sh
|
||||
$ gem install grpc-tools
|
||||
gem install grpc-tools
|
||||
```
|
||||
|
||||
### Download the example
|
||||
|
@ -41,9 +41,9 @@ and other tutorials):
|
|||
|
||||
```sh
|
||||
# Clone the repository to get the example code:
|
||||
$ git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
git clone -b {{< param grpc_vers.core >}} --depth 1 --shallow-submodules https://github.com/grpc/grpc
|
||||
# Navigate to the "hello, world" Ruby example:
|
||||
$ cd grpc/examples/ruby
|
||||
cd grpc/examples/ruby
|
||||
```
|
||||
|
||||
### Run a gRPC application
|
||||
|
@ -53,13 +53,13 @@ From the `examples/ruby` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ ruby greeter_server.rb
|
||||
ruby greeter_server.rb
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ruby greeter_client.rb
|
||||
ruby greeter_client.rb
|
||||
```
|
||||
|
||||
Congratulations! You've just run a client-server application with gRPC.
|
||||
|
@ -125,7 +125,7 @@ Next we need to update the gRPC code used by our application to use the new
|
|||
service definition. From the `examples/ruby/` directory:
|
||||
|
||||
```sh
|
||||
$ grpc_tools_ruby_protoc -I ../protos --ruby_out=lib --grpc_out=lib ../protos/helloworld.proto
|
||||
grpc_tools_ruby_protoc -I ../protos --ruby_out=lib --grpc_out=lib ../protos/helloworld.proto
|
||||
```
|
||||
|
||||
This regenerates `lib/helloworld_services_pb.rb`, which contains our generated
|
||||
|
@ -170,13 +170,13 @@ Just like we did before, from the `examples/ruby` directory:
|
|||
1. Run the server:
|
||||
|
||||
```sh
|
||||
$ ruby greeter_server.rb
|
||||
ruby greeter_server.rb
|
||||
```
|
||||
|
||||
2. From another terminal, run the client:
|
||||
|
||||
```sh
|
||||
$ ruby greeter_client.rb
|
||||
ruby greeter_client.rb
|
||||
```
|
||||
|
||||
### What's next
|
||||
|
|
|
@ -24,13 +24,13 @@ This guide also does not cover anything on the server side. You can check the [J
|
|||
The example code for our tutorial is in [grpc-java's examples/android](https://github.com/grpc/grpc-java/tree/{{< param grpc_vers.java >}}/examples/android). To download the example, clone the `grpc-java` repository by running the following command:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.java >}} https://github.com/grpc/grpc-java.git
|
||||
git clone -b {{< param grpc_vers.java >}} https://github.com/grpc/grpc-java.git
|
||||
```
|
||||
|
||||
Then change your current directory to `grpc-java/examples/android`:
|
||||
|
||||
```sh
|
||||
$ cd grpc-java/examples/android
|
||||
cd grpc-java/examples/android
|
||||
```
|
||||
|
||||
You also should have the relevant tools installed to generate the client
|
||||
|
|
|
@ -18,7 +18,7 @@ weight: 10
|
|||
the following environment variable:
|
||||
|
||||
```sh
|
||||
$ export ANDROID_SDK_ROOT="<path-to-your-android-sdk>"
|
||||
export ANDROID_SDK_ROOT="<path-to-your-android-sdk>"
|
||||
```
|
||||
|
||||
- An android device set up for [USB debugging][] or an
|
||||
|
@ -38,13 +38,13 @@ The example code is part of the [grpc-java][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone -b {{< param grpc_vers.java >}} https://github.com/grpc/grpc-java
|
||||
git clone -b {{< param grpc_vers.java >}} https://github.com/grpc/grpc-java
|
||||
```
|
||||
|
||||
2. Change to the examples directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-java/examples
|
||||
cd grpc-java/examples
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -52,20 +52,20 @@ The example code is part of the [grpc-java][] repo.
|
|||
1. Compile the server:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./build/install/examples/bin/hello-world-server
|
||||
./build/install/examples/bin/hello-world-server
|
||||
INFO: Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, build the client and install it on your device:
|
||||
|
||||
```sh
|
||||
$ (cd android/helloworld; ../../gradlew installDebug)
|
||||
(cd android/helloworld; ../../gradlew installDebug)
|
||||
```
|
||||
|
||||
4. Launch the client app from your device.
|
||||
|
@ -190,20 +190,20 @@ from the `examples` directory:
|
|||
1. Compile the server:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./build/install/examples/bin/hello-world-server
|
||||
./build/install/examples/bin/hello-world-server
|
||||
INFO: Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, build the client and install it on your device:
|
||||
|
||||
```sh
|
||||
$ (cd android/helloworld; ../../gradlew installDebug)
|
||||
(cd android/helloworld; ../../gradlew installDebug)
|
||||
```
|
||||
|
||||
4. Launch the client app from your device.
|
||||
|
@ -236,7 +236,7 @@ To run the app on a physical device via USB debugging, you must configure USB
|
|||
port forwarding using the `adb` command as follows:
|
||||
|
||||
```sh
|
||||
$ adb reverse tcp:8080 tcp:50051
|
||||
adb reverse tcp:8080 tcp:50051
|
||||
```
|
||||
|
||||
This sets up port forwarding from port `8080` on the device to port `50051` on
|
||||
|
|
|
@ -19,7 +19,7 @@ weight: 10
|
|||
the following environment variable:
|
||||
|
||||
```sh
|
||||
$ export ANDROID_SDK_ROOT="<path-to-your-android-sdk>"
|
||||
export ANDROID_SDK_ROOT="<path-to-your-android-sdk>"
|
||||
```
|
||||
|
||||
- An android device set up for [USB debugging][] or an
|
||||
|
@ -39,13 +39,13 @@ The example code is part of the [grpc-kotlin][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/grpc/grpc-kotlin
|
||||
git clone https://github.com/grpc/grpc-kotlin
|
||||
```
|
||||
|
||||
2. Change to the examples directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-kotlin/examples
|
||||
cd grpc-kotlin/examples
|
||||
```
|
||||
|
||||
### Run the example
|
||||
|
@ -53,20 +53,20 @@ The example code is part of the [grpc-kotlin][] repo.
|
|||
1. Compile the server:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./server/build/install/server/bin/hello-world-server
|
||||
./server/build/install/server/bin/hello-world-server
|
||||
Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, build the client and install it on your device:
|
||||
|
||||
```sh
|
||||
$ ./gradlew :android:installDebug
|
||||
./gradlew :android:installDebug
|
||||
```
|
||||
|
||||
4. Launch the client app from your device.
|
||||
|
@ -182,20 +182,20 @@ from the `examples` directory:
|
|||
1. Compile the server:
|
||||
|
||||
```sh
|
||||
$ ./gradlew installDist
|
||||
./gradlew installDist
|
||||
```
|
||||
|
||||
2. Run the server:
|
||||
|
||||
```sh
|
||||
$ ./server/build/install/server/bin/hello-world-server
|
||||
./server/build/install/server/bin/hello-world-server
|
||||
Server started, listening on 50051
|
||||
```
|
||||
|
||||
3. From another terminal, build the client and install it on your device:
|
||||
|
||||
```sh
|
||||
$ ./gradlew :android:installDebug
|
||||
./gradlew :android:installDebug
|
||||
```
|
||||
|
||||
4. Launch the client app from your device.
|
||||
|
|
|
@ -142,7 +142,7 @@ To generate the protobuf message classes from our `echo.proto`, run the
|
|||
following command:
|
||||
|
||||
```sh
|
||||
$ protoc -I=$DIR echo.proto \
|
||||
protoc -I=$DIR echo.proto \
|
||||
--js_out=import_style=commonjs:$OUT_DIR
|
||||
```
|
||||
|
||||
|
@ -155,14 +155,14 @@ protoc plugin. To compile the plugin `protoc-gen-grpc-web`, you need to run
|
|||
this from the repo's root directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-web
|
||||
$ sudo make install-plugin
|
||||
cd grpc-web
|
||||
sudo make install-plugin
|
||||
```
|
||||
|
||||
To generate the service client stub file, run this command:
|
||||
|
||||
```sh
|
||||
$ protoc -I=$DIR echo.proto \
|
||||
protoc -I=$DIR echo.proto \
|
||||
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:$OUT_DIR
|
||||
```
|
||||
|
||||
|
@ -214,8 +214,8 @@ Finally, putting all these together, we can compile all the relevant JS files
|
|||
into one single JS library that can be used in the browser.
|
||||
|
||||
```sh
|
||||
$ npm install
|
||||
$ npx webpack client.js
|
||||
npm install
|
||||
npx webpack client.js
|
||||
```
|
||||
|
||||
Now embed `dist/main.js` into your project and see it in action!
|
||||
|
|
|
@ -20,13 +20,13 @@ The example code is part of the [grpc-web][] repo.
|
|||
the repo:
|
||||
|
||||
```sh
|
||||
$ git clone https://github.com/grpc/grpc-web
|
||||
git clone https://github.com/grpc/grpc-web
|
||||
```
|
||||
|
||||
2. Change to the repo's root directory:
|
||||
|
||||
```sh
|
||||
$ cd grpc-web
|
||||
cd grpc-web
|
||||
```
|
||||
|
||||
### Run an Echo example from your browser!
|
||||
|
@ -36,7 +36,7 @@ From the `grpc-web` directory:
|
|||
1. Fetch required packages and tools:
|
||||
|
||||
```sh
|
||||
$ docker-compose pull prereqs node-server envoy commonjs-client
|
||||
docker-compose pull prereqs node-server envoy commonjs-client
|
||||
```
|
||||
|
||||
{{% alert title="Note" color="info" %}}
|
||||
|
@ -51,7 +51,7 @@ WARNING: Some service image(s) must be built from source
|
|||
2. Launch services as background processes:
|
||||
|
||||
```sh
|
||||
$ docker-compose up -d node-server envoy commonjs-client
|
||||
docker-compose up -d node-server envoy commonjs-client
|
||||
```
|
||||
|
||||
3. From your browser:
|
||||
|
@ -69,7 +69,7 @@ Once you are done, shutdown the services that you launched earlier by running
|
|||
the following command:
|
||||
|
||||
```sh
|
||||
$ docker-compose down
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### What is happening?
|
||||
|
|
|
@ -32,15 +32,15 @@ Linux or macOS using the following commands.
|
|||
- Linux, using `apt` or `apt-get`, for example:
|
||||
|
||||
```sh
|
||||
$ apt install -y protobuf-compiler
|
||||
$ protoc --version # Ensure compiler version is 3+
|
||||
apt install -y protobuf-compiler
|
||||
protoc --version # Ensure compiler version is 3+
|
||||
```
|
||||
|
||||
- MacOS, using [Homebrew][]:
|
||||
|
||||
```sh
|
||||
$ brew install protobuf
|
||||
$ protoc --version # Ensure compiler version is 3+
|
||||
brew install protobuf
|
||||
protoc --version # Ensure compiler version is 3+
|
||||
```
|
||||
|
||||
<a name="binary-install"></a>
|
||||
|
@ -56,22 +56,22 @@ binaries, follow these instructions:
|
|||
as the following:
|
||||
|
||||
```sh
|
||||
$ PB_REL="https://github.com/protocolbuffers/protobuf/releases"
|
||||
$ curl -LO $PB_REL/download/v{{< param protoc-version >}}/protoc-{{< param protoc-version >}}-linux-x86_64.zip
|
||||
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
|
||||
curl -LO $PB_REL/download/v{{< param protoc-version >}}/protoc-{{< param protoc-version >}}-linux-x86_64.zip
|
||||
```
|
||||
|
||||
2. Unzip the file under `$HOME/.local` or a directory of your choice. For
|
||||
example:
|
||||
|
||||
```sh
|
||||
$ unzip protoc-{{< param protoc-version >}}-linux-x86_64.zip -d $HOME/.local
|
||||
unzip protoc-{{< param protoc-version >}}-linux-x86_64.zip -d $HOME/.local
|
||||
```
|
||||
|
||||
3. Update your environment's path variable to include the path to the
|
||||
`protoc` executable. For example:
|
||||
|
||||
```sh
|
||||
$ export PATH="$PATH:$HOME/.local/bin"
|
||||
export PATH="$PATH:$HOME/.local/bin"
|
||||
```
|
||||
|
||||
### Other installation options
|
||||
|
|
Loading…
Reference in New Issue