feat: move the $ shell line indicator to scss (#1354)

This commit is contained in:
AJ Danelz 2024-11-25 11:33:41 -05:00 committed by GitHub
parent e2bace833a
commit ab8b3af6dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 343 additions and 317 deletions

View File

@ -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 The following contains some styles in use on the top-level pages
(About, Community...). Bootstrap provides many responsive utilities (About, Community...). Bootstrap provides many responsive utilities

View File

@ -41,8 +41,8 @@ To best follow along,
and clone the rules_protobuf repository: and clone the rules_protobuf repository:
```sh ```sh
~$ git clone https://github.com/pubref/rules_protobuf git clone https://github.com/pubref/rules_protobuf
~$ cd rules_protobuf cd rules_protobuf
~/rules_protobuf$ ~/rules_protobuf$
``` ```
@ -89,7 +89,7 @@ Let's look at the file tree, showing only those folder having a
`BUILD` file: `BUILD` file:
```diff ```diff
$ tree -P 'BUILD|WORKSPACE' -I 'third_party|bzl' examples/ tree -P 'BUILD|WORKSPACE' -I 'third_party|bzl' examples/
. .
├── BUILD ├── BUILD
├── WORKSPACE ├── WORKSPACE
@ -130,7 +130,7 @@ within the examples folder, and say what kind of thing it is in
addition to its path label"*: addition to its path label"*:
```sh ```bash
~/rules_protobuf$ bazel query //examples/... --output label_kind | sort | column -t ~/rules_protobuf$ bazel query //examples/... --output label_kind | sort | column -t
cc_binary rule //examples/helloworld/cpp:client 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 address targets in that workspace in the same way. Here's a partial
list: list:
```sh ```bash
~/rules_protobuf$ bazel query @com_github_google_protobuf//... --output label_kind | sort | column -t ~/rules_protobuf$ bazel query @com_github_google_protobuf//... --output label_kind | sort | column -t
cc_binary rule @com_github_google_protobuf//:protoc 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 from source, and call it (pass command line arguments to binary rules
after the double-dash): after the double-dash):
```sh ```bash
~/rules_protobuf$ bazel run @com_github_google_protobuf//:protoc -- --help ~/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 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: 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 For example, we can peek at the generated BUILD file for the
`maven_jar` guava dependency via: `maven_jar` guava dependency via:
```sh ```bash
~/rules_protobuf$ cat $(bazel info execution_root)/external/com_google_guava_guava/jar/BUILD ~/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 reports this reverse dependency set. We request the output in
graphviz format and pipe this to dot to generate the figure: 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)" \ ~/rules_protobuf$ bazel query "rdeps(deps(//examples/...), @com_github_madler_zlib//:zlib)" \
--output graph | dot -Tpng -O --output graph | dot -Tpng -O
``` ```
@ -461,7 +461,7 @@ simultaneously:
``` ```
```sh ```sh
$ bazel build :pluriproto bazel build :pluriproto
# ************************************************************ # ************************************************************
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_github_google_protobuf/protoc \ 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 \ --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: Here's the directory layout and relevant BUILD files we'll be using:
```sh ```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$ mkdir -p proto/ go/ java/org/pubref/grpc/greetertimer/
~/grpc_greetertimer$ touch WORKSPACE ~/grpc_greetertimer$ touch WORKSPACE
~/grpc_greetertimer$ touch proto/BUILD ~/grpc_greetertimer$ touch proto/BUILD
@ -795,7 +795,7 @@ go_binary(
) )
``` ```
```sh ```bash
~/grpc_greetertimer$ bazel build //go:client ~/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: 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
~/grpc_greetertimer$ bazel build java/org/pubref/grpc/greetertimer:server_deploy.jar ~/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): First, we'll start a greeter server (one at a time):
```sh ```bash
~/grpc_greetertimer$ cd ~/rules_protobuf ~/grpc_greetertimer$ cd ~/rules_protobuf
~/rules_protobuf$ bazel run examples/helloworld/go/server ~/rules_protobuf$ bazel run examples/helloworld/go/server
~/rules_protobuf$ bazel run examples/helloworld/cpp/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: In a separate terminal, start the greetertimer server:
```sh ```bash
~/grpc_greetertimer$ bazel build //java/org/pubref/grpc/greetertimer:server_deploy.jar ~/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 ~/grpc_greetertimer$ java -jar bazel-bin/java/org/pubref/grpc/greetertimer/server_deploy.jar
``` ```

View File

@ -57,7 +57,7 @@ service EchoService {
This means the gateway, once generated by `protoc`, can now accept a HTTP request from `curl` like this: This means the gateway, once generated by `protoc`, can now accept a HTTP request from `curl` like this:
```sh ```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: 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: To try it out, all you need is a working Go 1.6 development environment and the following simple commands:
```sh ```sh
$ go get -u github.com/philips/grpc-gateway-example go get -u github.com/philips/grpc-gateway-example
$ grpc-gateway-example serve grpc-gateway-example serve
``` ```
With the server running you can try requests on both HTTP 1.1 and gRPC interfaces: With the server running you can try requests on both HTTP 1.1 and gRPC interfaces:
```sh ```sh
$ grpc-gateway-example echo Take a REST from REST with gRPC 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!"}' 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. 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.

View File

@ -37,7 +37,7 @@ directory
Let's start by creating a new library project. Let's start by creating a new library project.
```sh ```bash
~/work$ dotnet new classlib -o MyGreeter ~/work$ dotnet new classlib -o MyGreeter
The template "Class library" was created successfully. 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) ](https://github.com/grpc/grpc/blob/master/examples/protos/helloworld.proto)
from the gRPC distribution. from the gRPC distribution.
```sh ```bash
~/work/MyGreeter$ rm Class1.cs ~/work/MyGreeter$ rm Class1.cs
~/work/MyGreeter$ wget -q https://raw.githubusercontent.com/grpc/grpc/master/examples/protos/helloworld.proto ~/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: Next, add required NuGet packages to the project:
```sh ```bash
~/work/MyGreeter$ dotnet add package Grpc ~/work/MyGreeter$ dotnet add package Grpc
info : PackageReference for package 'Grpc' version '1.17.0' added to file '/home/kkm/work/MyGreeter/MyGreeter.csproj'. 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 ~/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 Note that many output lines are omitted below, as the build output is quite
verbose. verbose.
```sh ```bash
~/work/MyGreeter$ dotnet build -v:n ~/work/MyGreeter$ dotnet build -v:n
Build started 11/9/18 5:33:44 PM. 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 tools like the debugger. You can see other autogenerated sources in that
directory, too: directory, too:
```sh ```bash
~/work/MyGreeter$ find obj -name '*.cs' ~/work/MyGreeter$ find obj -name '*.cs'
obj/Debug/netstandard2.0/MyGreeter.AssemblyInfo.cs obj/Debug/netstandard2.0/MyGreeter.AssemblyInfo.cs
obj/Debug/netstandard2.0/Helloworld.cs obj/Debug/netstandard2.0/Helloworld.cs

View File

@ -78,7 +78,7 @@ service TodoService {
CommonJS client-side code can be generated from this `.proto` definition with the following command: CommonJS client-side code can be generated from this `.proto` definition with the following command:
```sh ```sh
$ protoc echo.proto \ protoc echo.proto \
--js_out=import_style=commonjs:./output \ --js_out=import_style=commonjs:./output \
--grpc-web_out=import_style=commonjs:./output --grpc-web_out=import_style=commonjs:./output
``` ```

View File

@ -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: 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 ```sh
$ ./gradlew :dependencies | grep -i proto ./gradlew :dependencies | grep -i proto
$ # no proto deps! # no proto deps!
``` ```
## Optimizing the Code ## 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: 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 ```sh
$ ./gradlew installDist ./gradlew installDist
$ time ./build/install/kvstore/bin/kvstore time ./build/install/kvstore/bin/kvstore
INFO: Did 215.883 RPCs/s 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: Using this in our marshallers, we can see a dramatic performance difference:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
$ time ./build/install/kvstore/bin/kvstore time ./build/install/kvstore/bin/kvstore
INFO: Did 2,202.2 RPCs/s INFO: Did 2,202.2 RPCs/s
``` ```

View File

@ -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: Ubuntu system with a 12 core processor and 32 GB of memory. Let's build and run the code:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
$ time ./build/install/kvstore/bin/kvstore time ./build/install/kvstore/bin/kvstore
Feb 26, 2018 1:10:07 PM io.grpc.examples.KvRunner runClient Feb 26, 2018 1:10:07 PM io.grpc.examples.KvRunner runClient
INFO: Starting INFO: Starting
Feb 26, 2018 1:11:07 PM io.grpc.examples.KvRunner runClient 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: Building and running the code again looks a lot better:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
$ time ./build/install/kvstore/bin/kvstore time ./build/install/kvstore/bin/kvstore
Feb 26, 2018 2:40:47 PM io.grpc.examples.KvRunner runClient Feb 26, 2018 2:40:47 PM io.grpc.examples.KvRunner runClient
INFO: Starting INFO: Starting
Feb 26, 2018 2:41:47 PM io.grpc.examples.KvRunner runClient Feb 26, 2018 2:41:47 PM io.grpc.examples.KvRunner runClient

View File

@ -170,8 +170,8 @@ per RPC, but a lot more are happening at the same time. Let's see if our hypoth
Before: Before:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
$ time ./build/install/kvstore/bin/kvstore time ./build/install/kvstore/bin/kvstore
Apr 16, 2018 10:38:42 AM io.grpc.examples.KvRunner runClient Apr 16, 2018 10:38:42 AM io.grpc.examples.KvRunner runClient
INFO: Did 24.067 RPCs/s INFO: Did 24.067 RPCs/s

View File

@ -36,14 +36,14 @@ Get the example code and build gRPC:
2. From the repo folder, change to the route guide example directory: 2. From the repo folder, change to the route guide example directory:
```sh ```sh
$ cd examples/cpp/route_guide cd examples/cpp/route_guide
``` ```
3. Run `cmake` 3. Run `cmake`
```sh ```sh
$ mkdir -p cmake/build mkdir -p cmake/build
$ cd cmake/build cd cmake/build
$ cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../.. cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
``` ```
### Defining the service ### 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): the gRPC code [installation instructions](https://github.com/grpc/grpc/blob/{{< param grpc_vers.core >}}/src/cpp/README.md#cmake) first):
```sh ```sh
$ make route_guide.grpc.pb.o make route_guide.grpc.pb.o
``` ```
which actually runs: which actually runs:
```sh ```sh
$ protoc -I ../../protos --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../../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 protoc -I ../../protos --cpp_out=. ../../protos/route_guide.proto
``` ```
Running this command generates the following files in your current directory: Running this command generates the following files in your current directory:
@ -502,19 +502,19 @@ independently.
Build the client and server: Build the client and server:
```sh ```sh
$ make make
``` ```
Run the server: Run the server:
```sh ```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: From a different terminal, run the client:
```sh ```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" >}} [build and locally install gRPC from source]: {{< relref "quickstart#install-grpc" >}}

View File

@ -26,37 +26,37 @@ example:
- Linux / macOS - Linux / macOS
```sh ```sh
$ export MY_INSTALL_DIR=$HOME/.local export MY_INSTALL_DIR=$HOME/.local
``` ```
Ensure that the directory exists: Ensure that the directory exists:
```sh ```sh
$ mkdir -p $MY_INSTALL_DIR mkdir -p $MY_INSTALL_DIR
``` ```
Add the local `bin` folder to your path variable, for example: Add the local `bin` folder to your path variable, for example:
```sh ```sh
$ export PATH="$MY_INSTALL_DIR/bin:$PATH" export PATH="$MY_INSTALL_DIR/bin:$PATH"
``` ```
- Windows - Windows
```sh ```powershell
> set MY_INSTALL_DIR=%USERPROFILE%\cmake set MY_INSTALL_DIR=%USERPROFILE%\cmake
``` ```
Ensure that the directory exists: Ensure that the directory exists:
``` ```powershell
> mkdir %INSTALL_DIR% mkdir %INSTALL_DIR%
``` ```
Add the local `bin` folder to your path variable, for example: Add the local `bin` folder to your path variable, for example:
```sh ```powershell
> set PATH=%PATH%;$MY_INSTALL_DIR\bin set PATH=%PATH%;$MY_INSTALL_DIR\bin
``` ```
#### Install cmake #### Install cmake
@ -67,19 +67,19 @@ following these instructions if you don't have it:
- Linux - Linux
```sh ```sh
$ sudo apt install -y cmake sudo apt install -y cmake
``` ```
- macOS: - macOS:
```sh ```sh
$ brew install cmake brew install cmake
``` ```
- Windows: - Windows:
```sh ```sh
$ choco install cmake choco install cmake
``` ```
- For general `cmake` installation instructions, see [Installing 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`: Check the version of `cmake`:
```sh ```sh
$ cmake --version cmake --version
cmake version {{< param cmake-version >}} cmake version {{< param cmake-version >}}
``` ```
@ -96,9 +96,9 @@ can install a more recent version into your local installation directory as
follows: follows:
```sh ```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 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 sh cmake-linux.sh -- --skip-license --prefix=$MY_INSTALL_DIR
$ rm cmake-linux.sh rm cmake-linux.sh
``` ```
#### Install other required tools #### Install other required tools
@ -108,13 +108,13 @@ Install the basic tools required to build gRPC:
- Linux - Linux
```sh ```sh
$ sudo apt install -y build-essential autoconf libtool pkg-config sudo apt install -y build-essential autoconf libtool pkg-config
``` ```
- macOS: - macOS:
```sh ```sh
$ brew install autoconf automake libtool pkg-config brew install autoconf automake libtool pkg-config
``` ```
#### Clone the `grpc` repo #### Clone the `grpc` repo
@ -122,7 +122,7 @@ Install the basic tools required to build gRPC:
Clone the `grpc` repo and its submodules: Clone the `grpc` repo and its submodules:
```sh ```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 #### Build and install gRPC and Protocol Buffers
@ -135,26 +135,26 @@ The following commands build and locally install gRPC and Protocol Buffers:
- Linux & macOS - Linux & macOS
```sh ```sh
$ cd grpc cd grpc
$ mkdir -p cmake/build mkdir -p cmake/build
$ pushd cmake/build pushd cmake/build
$ cmake -DgRPC_INSTALL=ON \ cmake -DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \ -DgRPC_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \ -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
../.. ../..
$ make -j 4 make -j 4
$ make install make install
$ popd popd
``` ```
- Windows - Windows
```sh ```powershell
> mkdir "cmake\build" mkdir "cmake\build"
> pushd "cmake\build" pushd "cmake\build"
> cmake -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% -DgRPC_BUILD_TESTS=OFF ..\.. cmake -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% -DgRPC_BUILD_TESTS=OFF ..\..
> cmake --build . --config Release --target install -j 4 cmake --build . --config Release --target install -j 4
> popd popd
``` ```
{{% alert title="Important" color="warning" %}} {{% alert title="Important" color="warning" %}}
@ -178,7 +178,7 @@ the steps of the previous section.
1. Change to the example's directory: 1. Change to the example's directory:
```sh ```sh
$ cd examples/cpp/helloworld cd examples/cpp/helloworld
``` ```
2. Build the example using `cmake`: 2. Build the example using `cmake`:
@ -186,20 +186,20 @@ the steps of the previous section.
- Linux & macOS - Linux & macOS
```sh ```sh
$ mkdir -p cmake/build mkdir -p cmake/build
$ pushd cmake/build pushd cmake/build
$ cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../.. cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
$ make -j 4 make -j 4
``` ```
- Windows - Windows
```sh ```powershell
> mkdir "cmake\build" mkdir "cmake\build"
> pushd "cmake\build" pushd "cmake\build"
> cmake -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% ..\.. cmake -DCMAKE_INSTALL_PREFIX=%MY_INSTALL_DIR% ..\..
> cmake --build . --config Release -j 4 cmake --build . --config Release -j 4
> popd popd
``` ```
{{% alert title="Note" color="info" %}} {{% alert title="Note" color="info" %}}
@ -216,13 +216,13 @@ Run the example from the example **build** directory
1. Run the server: 1. Run the server:
```sh ```sh
$ ./greeter_server ./greeter_server
``` ```
1. From a different terminal, run the client and see the client output: 1. From a different terminal, run the client and see the client output:
```sh ```sh
$ ./greeter_client ./greeter_client
Greeter received: Hello world Greeter received: Hello world
``` ```
@ -291,14 +291,14 @@ From the example **build** directory `examples/cpp/helloworld/cmake/build`, run:
- Linux & macOS - Linux & macOS
```sh ```powershell
$ make -j 4 make -j 4
``` ```
- Windows - Windows
```sh ```powershell
> cmake --build . --config Release -j 4 cmake --build . --config Release -j 4
``` ```
This regenerates `helloworld.pb.{h,cc}` and `helloworld.grpc.pb.{h,cc}`, which 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 - Linux & macOS
```sh ```sh
$ make -j 4 make -j 4
``` ```
- Windows - Windows
```sh ```powershell
> cmake --build . --config Release -j 4 cmake --build . --config Release -j 4
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./greeter_server ./greeter_server
``` ```
3. On a different terminal, run the client: 3. On a different terminal, run the client:
```sh ```sh
$ ./greeter_client ./greeter_client
``` ```
You'll see the following output: You'll see the following output:

View File

@ -33,13 +33,13 @@ To download the example, clone the `grpc-dart` repository by running the followi
command: command:
```sh ```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`: Then change your current directory to `grpc-dart/example/route_guide`:
```sh ```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 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: Work from the example directory:
```sh ```sh
$ cd example/route_guide cd example/route_guide
``` ```
Get packages: Get packages:
```sh ```sh
$ dart pub get dart pub get
``` ```
Run the server: Run the server:
```sh ```sh
$ dart bin/server.dart dart bin/server.dart
``` ```
From a different terminal, run the client: From a different terminal, run the client:
```sh ```sh
$ dart bin/client.dart dart bin/client.dart
``` ```
### Reporting issues ### Reporting issues

View File

@ -22,13 +22,13 @@ spelling: cSpell:ignore Iprotos
the following command: the following command:
```sh ```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: 2. Update your `PATH` so that the `protoc` compiler can find the plugin:
```sh ```sh
$ export PATH="$PATH:$HOME/.pub-cache/bin" export PATH="$PATH:$HOME/.pub-cache/bin"
``` ```
{{% alert title="Note" color="info" %}} {{% alert title="Note" color="info" %}}
@ -43,13 +43,13 @@ The example code is part of the [grpc-dart][] repo.
the repo: the repo:
```sh ```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: 2. Change to the quick start example directory:
```sh ```sh
$ cd grpc-dart/example/helloworld cd grpc-dart/example/helloworld
``` ```
### Run the example ### Run the example
@ -59,19 +59,19 @@ From the `example/helloworld` directory:
1. Download package dependencies: 1. Download package dependencies:
```sh ```sh
$ dart pub get dart pub get
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ dart bin/server.dart dart bin/server.dart
``` ```
3. From another terminal, run the client: 3. From another terminal, run the client:
```sh ```sh
$ dart bin/client.dart dart bin/client.dart
Greeter client received: Hello, world! 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: proto file. From the `example/helloworld` directory, run the following command:
```sh ```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 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: 1. Run the server:
```sh ```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 2. From another terminal, run the client. This time, add a name as a command-line
argument: argument:
```sh ```sh
$ dart bin/client.dart Alice dart bin/client.dart Alice
``` ```
You'll see the following output: You'll see the following output:

View File

@ -40,13 +40,13 @@ The example code is part of the [grpc-go][] repo.
the repo: the repo:
```sh ```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: 2. Change to the example directory:
```sh ```sh
$ cd grpc-go/examples/route_guide cd grpc-go/examples/route_guide
``` ```
### Defining the service ### 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: From the `examples/route_guide` directory, run the following command:
```sh ```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 \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \
routeguide/route_guide.proto routeguide/route_guide.proto
``` ```
@ -566,13 +566,13 @@ Execute the following commands from the `examples/route_guide` directory:
1. Run the server: 1. Run the server:
```sh ```sh
$ go run server/server.go go run server/server.go
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ go run client/client.go go run client/client.go
``` ```
You'll see output like this: You'll see output like this:

View File

@ -21,14 +21,14 @@ spelling: cSpell:ignore Fatalf GOPATH
1. Install the protocol compiler plugins for Go using the following commands: 1. Install the protocol compiler plugins for Go using the following commands:
```sh ```sh
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 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/grpc/cmd/protoc-gen-go-grpc@latest
``` ```
2. Update your `PATH` so that the `protoc` compiler can find the plugins: 2. Update your `PATH` so that the `protoc` compiler can find the plugins:
```sh ```sh
$ export PATH="$PATH:$(go env GOPATH)/bin" export PATH="$PATH:$(go env GOPATH)/bin"
``` ```
### Get the example code ### Get the example code
@ -39,13 +39,13 @@ The example code is part of the [grpc-go][] repo.
the repo: the repo:
```sh ```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: 2. Change to the quick start example directory:
```sh ```sh
$ cd grpc-go/examples/helloworld cd grpc-go/examples/helloworld
``` ```
### Run the example ### Run the example
@ -55,14 +55,14 @@ From the `examples/helloworld` directory:
1. Compile and execute the server code: 1. Compile and execute the server code:
```sh ```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 2. From a different terminal, compile and execute the client code to see the
client output: client output:
```sh ```sh
$ go run greeter_client/main.go go run greeter_client/main.go
Greeting: Hello world 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: While still in the `examples/helloworld` directory, run the following command:
```sh ```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 \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \
helloworld/helloworld.proto helloworld/helloworld.proto
``` ```
@ -178,14 +178,14 @@ from the `examples/helloworld` directory:
1. Run the server: 1. Run the server:
```sh ```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 2. From another terminal, run the client. This time, add a name as a
command-line argument: command-line argument:
```sh ```sh
$ go run greeter_client/main.go --name=Alice go run greeter_client/main.go --name=Alice
``` ```
You'll see the following output: You'll see the following output:

View File

@ -35,13 +35,13 @@ To download the example, clone the latest release in `grpc-java` repository by
running the following command: running the following command:
```sh ```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`: Then change your current directory to `grpc-java/examples`:
```sh ```sh
$ cd grpc-java/examples cd grpc-java/examples
``` ```
### Defining the service ### Defining the service

View File

@ -316,6 +316,6 @@ If you wish to invoke the protobuf plugin for gRPC Java directly,
the command-line syntax is as follows: the command-line syntax is as follows:
```sh ```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" --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
``` ```

View File

@ -16,13 +16,13 @@ The example code is part of the [grpc-java][] repo.
the repo: the repo:
```sh ```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: 2. Change to the examples directory:
```sh ```sh
$ cd grpc-java/examples cd grpc-java/examples
``` ```
### Run the example ### Run the example
@ -32,20 +32,20 @@ From the `examples` directory:
1. Compile the client and server 1. Compile the client and server
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./build/install/examples/bin/hello-world-server ./build/install/examples/bin/hello-world-server
INFO: Server started, listening on 50051 INFO: Server started, listening on 50051
``` ```
3. From another terminal, run the client: 3. From another terminal, run the client:
```sh ```sh
$ ./build/install/examples/bin/hello-world-client ./build/install/examples/bin/hello-world-client
INFO: Will try to greet world ... INFO: Will try to greet world ...
INFO: Greeting: Hello world INFO: Greeting: Hello world
``` ```
@ -206,20 +206,20 @@ from the `examples` directory:
1. Compile the client and server: 1. Compile the client and server:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./build/install/examples/bin/hello-world-server ./build/install/examples/bin/hello-world-server
INFO: Server started, listening on 50051 INFO: Server started, listening on 50051
``` ```
3. From another terminal, run the client: 3. From another terminal, run the client:
```sh ```sh
$ ./build/install/examples/bin/hello-world-client ./build/install/examples/bin/hello-world-client
INFO: Will try to greet world ... INFO: Will try to greet world ...
INFO: Greeting: Hello world INFO: Greeting: Hello world
INFO: Greeting: Hello again world INFO: Greeting: Hello again world

View File

@ -34,13 +34,13 @@ The example code is part of the [grpc-kotlin][] repo.
the repo: the repo:
```sh ```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: 2. Change to the examples directory:
```sh ```sh
$ cd grpc-kotlin/examples cd grpc-kotlin/examples
``` ```
### Defining the service ### Defining the service
@ -474,20 +474,20 @@ Run the following commands from the `grpc-kotlin/examples` directory:
1. Compile the client and server 1. Compile the client and server
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./server/build/install/server/bin/route-guide-server ./server/build/install/server/bin/route-guide-server
Server started, listening on 8980 Server started, listening on 8980
``` ```
3. From another terminal, run the client: 3. From another terminal, run the client:
```sh ```sh
$ ./client/build/install/client/bin/route-guide-client ./client/build/install/client/bin/route-guide-client
``` ```
You'll see client output like this: You'll see client output like this:

View File

@ -18,13 +18,13 @@ The example code is part of the [grpc-kotlin][] repo.
the repo: the repo:
```sh ```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: 2. Change to the examples directory:
```sh ```sh
$ cd grpc-kotlin/examples cd grpc-kotlin/examples
``` ```
### Run the example ### Run the example
@ -34,20 +34,20 @@ From the `examples` directory:
1. Compile the client and server 1. Compile the client and server
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./server/build/install/server/bin/hello-world-server ./server/build/install/server/bin/hello-world-server
Server started, listening on 50051 Server started, listening on 50051
``` ```
3. From another terminal, run the client: 3. From another terminal, run the client:
```sh ```sh
$ ./client/build/install/client/bin/hello-world-client ./client/build/install/client/bin/hello-world-client
Received: Hello world Received: Hello world
``` ```
@ -169,13 +169,13 @@ from the `examples` directory:
1. Compile the client and server: 1. Compile the client and server:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./server/build/install/server/bin/hello-world-server ./server/build/install/server/bin/hello-world-server
Server started, listening on 50051 Server started, listening on 50051
``` ```
@ -183,7 +183,7 @@ from the `examples` directory:
command-line argument: command-line argument:
```sh ```sh
$ ./client/build/install/client/bin/hello-world-client Alice ./client/build/install/client/bin/hello-world-client Alice
Received: Hello Alice Received: Hello Alice
Received: Hello again Alice Received: Hello again Alice
``` ```

View File

@ -45,14 +45,14 @@ To download the example, clone the `grpc` repository by running the following
command: command:
```sh ```sh
$ 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
$ cd grpc cd grpc
``` ```
Then change your current directory to `examples`: Then change your current directory to `examples`:
```sh ```sh
$ cd examples cd examples
``` ```
You also should have the relevant tools installed to generate the server and You also should have the relevant tools installed to generate the server and
@ -495,17 +495,17 @@ independently.
Build the client and server: Build the client and server:
```sh ```sh
$ npm install npm install
``` ```
Run the server: Run the server:
```sh ```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: From a different terminal, run the client:
```sh ```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
``` ```

View File

@ -18,13 +18,13 @@ and other tutorials):
```sh ```sh
# Clone the repository to get the example code # 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 # Navigate to the node example
$ cd grpc-node/examples cd grpc-node/examples
# Install the example's dependencies # Install the example's dependencies
$ npm install npm install
# Navigate to the dynamic codegen "hello, world" Node example: # Navigate to the dynamic codegen "hello, world" Node example:
$ cd helloworld/dynamic_codegen cd helloworld/dynamic_codegen
``` ```
### Run a gRPC application ### Run a gRPC application
@ -34,13 +34,13 @@ From the `examples/helloworld/dynamic_codegen` directory:
1. Run the server: 1. Run the server:
```sh ```sh
$ node greeter_server.js node greeter_server.js
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ node greeter_client.js node greeter_client.js
``` ```
Congratulations! You've just run a client-server application with gRPC. 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: 1. Run the server:
```sh ```sh
$ node greeter_server.js node greeter_server.js
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ node greeter_client.js node greeter_client.js
``` ```
### What's next ### What's next

View File

@ -34,15 +34,15 @@ To download the example, clone the `grpc` repository by running the following
commands: commands:
```sh ```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
$ cd grpc cd grpc
$ git submodule update --init git submodule update --init
``` ```
Then change your current directory to `examples/objective-c/route_guide`: Then change your current directory to `examples/objective-c/route_guide`:
```sh ```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 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: run, for example, the C++ server in this repository:
```sh ```sh
$ pushd ../../cpp/route_guide pushd ../../cpp/route_guide
$ make make
$ ./route_guide_server & ./route_guide_server &
$ popd popd
``` ```
Now have Cocoapods generate and install the client library for our .proto files: Now have Cocoapods generate and install the client library for our .proto files:
```sh ```sh
$ pod install pod install
``` ```
(This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods (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`): directory (`examples/objective-c/route_guide`):
```sh ```sh
$ pod install pod install
``` ```
which, before installing the generated library in the XCode project of this sample, runs: which, before installing the generated library in the XCode project of this sample, runs:
```sh ```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/`: Running this command generates the following files under `Pods/RouteGuide/`:

View File

@ -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: download the example, clone this repository by running the following commands:
```sh ```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
$ cd grpc cd grpc
$ git submodule update --init git submodule update --init
``` ```
Then change your current directory to `examples/objective-c/auth_sample`: Then change your current directory to `examples/objective-c/auth_sample`:
```sh ```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 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: files:
```sh ```sh
$ pod install pod install
``` ```
(This might have to compile OpenSSL, which takes around 15 minutes if CocoaPods (This might have to compile OpenSSL, which takes around 15 minutes if CocoaPods

View File

@ -18,7 +18,7 @@ weight: 10
Check the status and version of CocoaPods on your system: Check the status and version of CocoaPods on your system:
```sh ```sh
$ pod --version pod --version
``` ```
If CocoaPods is not installed, follow the [CocoaPods install If CocoaPods is not installed, follow the [CocoaPods install
@ -32,7 +32,7 @@ weight: 10
Make sure the command line developer tools are installed: Make sure the command line developer tools are installed:
```sh ```sh
$ xcode-select --install xcode-select --install
``` ```
- [Homebrew](https://brew.sh/) - [Homebrew](https://brew.sh/)
@ -40,7 +40,7 @@ weight: 10
- `autoconf`, `automake`, `libtool`, `pkg-config` - `autoconf`, `automake`, `libtool`, `pkg-config`
```sh ```sh
$ brew install autoconf automake libtool pkg-config brew install autoconf automake libtool pkg-config
``` ```
### Download the example ### Download the example
@ -50,22 +50,22 @@ Quickstart. Copy the source code from GitHub
[repository](https://github.com/grpc/grpc): [repository](https://github.com/grpc/grpc):
```sh ```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 ### Install gRPC plugins and libraries
```sh ```sh
$ cd grpc cd grpc
$ make make
$ [sudo] make install [sudo] make install
``` ```
### Install protoc compiler ### Install protoc compiler
```sh ```sh
$ brew tap grpc/grpc brew tap grpc/grpc
$ brew install protobuf brew install protobuf
``` ```
### Run the server: ### 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: instead we build and run the C++ server in the same repository:
```sh ```sh
$ cd examples/cpp/helloworld cd examples/cpp/helloworld
$ make make
$ ./greeter_server & ./greeter_server &
``` ```
### Run the client: ### 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: well as installing several dependencies:
```sh ```sh
$ cd ../../objective-c/helloworld cd ../../objective-c/helloworld
$ pod install pod install
``` ```
(This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods (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: Open the Xcode workspace created by CocoaPods:
```sh ```sh
$ open HelloWorld.xcworkspace open HelloWorld.xcworkspace
``` ```
This will open the app project with Xcode. Run the app in an iOS simulator 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: First terminate the server process already running in the background:
```sh ```sh
$ pkill greeter_server pkill greeter_server
``` ```
Then in directory `examples/cpp/helloworld`, build and run the updated server Then in directory `examples/cpp/helloworld`, build and run the updated server
with the following commands: with the following commands:
```sh ```sh
$ make make
$ ./greeter_server & ./greeter_server &
``` ```
Change directory to `examples/objective-c/helloworld`, then clean up and Change directory to `examples/objective-c/helloworld`, then clean up and
reinstall Pods for the client app with the following commands: reinstall Pods for the client app with the following commands:
```sh ```sh
$ rm -Rf Pods rm -Rf Pods
$ rm Podfile.lock rm Podfile.lock
$ rm -Rf HelloWorld.xcworkspace rm -Rf HelloWorld.xcworkspace
$ pod install pod install
``` ```
This regenerates files in `Pods/HelloWorld` based on the new proto file we wrote This regenerates files in `Pods/HelloWorld` based on the new proto file we wrote
above. Open the client Xcode project in Xcode: above. Open the client Xcode project in Xcode:
```sh ```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, 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: : Install an older version of `activesupport`, then install CocoaPods:
```sh ```sh
$ [sudo] gem install activesupport -v 4.2.6 [sudo] gem install activesupport -v 4.2.6
$ [sudo] gem install cocoapods [sudo] gem install cocoapods
``` ```
When installing dependencies with CocoaPods, error `Unable to find a specification for !ProtoCompiler-gRPCPlugin` When installing dependencies with CocoaPods, error `Unable to find a specification for !ProtoCompiler-gRPCPlugin`

View File

@ -33,25 +33,25 @@ To download the example, clone the `grpc` repository and its submodules by runni
command: command:
```sh ```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: You need the `grpc-php-plugin` to help you compile `.proto` files. Build it from source as follows:
```sh ```sh
$ cd grpc cd grpc
$ mkdir -p cmake/build mkdir -p cmake/build
$ pushd cmake/build pushd cmake/build
$ cmake ../.. cmake ../..
$ make protoc grpc_php_plugin make protoc grpc_php_plugin
$ popd popd
``` ```
Then change to route guide directory and compile the example's `.proto` files: Then change to route guide directory and compile the example's `.proto` files:
```sh ```sh
$ cd examples/php/route_guide cd examples/php/route_guide
$ ./route_guide_proto_gen.sh ./route_guide_proto_gen.sh
``` ```
Our example is a simple route mapping application that lets clients get 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: run, for example, the Node.js server in this repository:
```sh ```sh
$ cd ../../node cd ../../node
$ npm install npm install
$ cd dynamic_codegen/route_guide cd dynamic_codegen/route_guide
$ nodejs ./route_guide_server.js --db_path=route_guide_db.json nodejs ./route_guide_server.js --db_path=route_guide_db.json
``` ```
Run the PHP client (in a different terminal): Run the PHP client (in a different terminal):
```sh ```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 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: gRPC PHP Protoc Plugin. To compile the plugin:
```sh ```sh
$ make grpc_php_plugin make grpc_php_plugin
``` ```
To generate the client stub implementation .php file: To generate the client stub implementation .php file:
```sh ```sh
$ cd grpc cd grpc
$ protoc --proto_path=examples/protos \ protoc --proto_path=examples/protos \
--php_out=examples/php/route_guide \ --php_out=examples/php/route_guide \
--grpc_out=examples/php/route_guide \ --grpc_out=examples/php/route_guide \
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \ --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: grpc-php-plugin by source:
```sh ```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. A number of files will be generated in the `examples/php/route_guide` directory.

View File

@ -23,20 +23,20 @@ The example code is part of the [grpc][] repo.
1. Clone the [grpc][] repo and its submodules: 1. Clone the [grpc][] repo and its submodules:
```sh ```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: 2. Change to the quick start example directory:
```sh ```sh
$ cd grpc/examples/php cd grpc/examples/php
``` ```
3. Install the `grpc` composer package: 3. Install the `grpc` composer package:
```sh ```sh
$ ./greeter_proto_gen.sh ./greeter_proto_gen.sh
$ composer install composer install
``` ```
### Run the example ### 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: 2. From the `examples/php` directory, run the PHP client:
```sh ```sh
$ ./run_greeter_client.sh ./run_greeter_client.sh
``` ```
Congratulations! You've just run a client-server application with gRPC. 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: service definition. From the `grpc` root directory:
```sh ```sh
$ protoc --proto_path=examples/protos \ protoc --proto_path=examples/protos \
--php_out=examples/php \ --php_out=examples/php \
--grpc_out=examples/php \ --grpc_out=examples/php \
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \ --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: grpc-php-plugin by source:
```sh ```sh
$ ./greeter_proto_gen.sh ./greeter_proto_gen.sh
``` ```
This regenerates the protobuf files, which contain our generated client classes, 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: 1. Run the server:
```sh ```sh
$ node greeter_server.js node greeter_server.js
``` ```
2. From another terminal, from the `examples/php` directory, 2. From another terminal, from the `examples/php` directory,
run the client: run the client:
```sh ```sh
$ ./run_greeter_client.sh ./run_greeter_client.sh
``` ```
### What's next ### What's next

View File

@ -33,13 +33,13 @@ To download the example, clone the `grpc` repository by running the following
command: command:
```sh ```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: Then change your current directory to `examples/python/route_guide` in the repository:
```sh ```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 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: First, install the grpcio-tools package:
```sh ```sh
$ pip install grpcio-tools pip install grpcio-tools
``` ```
Use the following command to generate the Python code: Use the following command to generate the Python code:
```sh ```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 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: Here's an example command to generate the gRPC client interfaces with a custom package path:
```sh ```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=. \ --python_out=. --grpc_python_out=. \
../../protos/route_guide.proto ../../protos/route_guide.proto
``` ```
@ -414,11 +414,11 @@ for received_route_note in stub.RouteChat(sent_route_note_iterator):
Run the server: Run the server:
```sh ```sh
$ python route_guide_server.py python route_guide_server.py
``` ```
From a different terminal, run the client: From a different terminal, run the client:
```sh ```sh
$ python route_guide_client.py python route_guide_client.py
``` ```

View File

@ -13,17 +13,17 @@ weight: 10
If necessary, upgrade your version of `pip`: If necessary, upgrade your version of `pip`:
```sh ```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 If you cannot upgrade `pip` due to a system-owned installation, you can
run the example in a virtualenv: run the example in a virtualenv:
```sh ```sh
$ python -m pip install virtualenv python -m pip install virtualenv
$ virtualenv venv virtualenv venv
$ source venv/bin/activate source venv/bin/activate
$ python -m pip install --upgrade pip python -m pip install --upgrade pip
``` ```
#### gRPC #### gRPC
@ -31,13 +31,13 @@ $ python -m pip install --upgrade pip
Install gRPC: Install gRPC:
```sh ```sh
$ python -m pip install grpcio python -m pip install grpcio
``` ```
Or, to install it system wide: Or, to install it system wide:
```sh ```sh
$ sudo python -m pip install grpcio sudo python -m pip install grpcio
``` ```
#### gRPC tools #### gRPC tools
@ -53,7 +53,7 @@ tutorials and your own projects.
To install gRPC tools, run: To install gRPC tools, run:
```sh ```sh
$ python -m pip install grpcio-tools python -m pip install grpcio-tools
``` ```
### Download the example ### Download the example
@ -65,9 +65,9 @@ and other tutorials):
```sh ```sh
# Clone the repository to get the example code: # 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: # Navigate to the "hello, world" Python example:
$ cd grpc/examples/python/helloworld cd grpc/examples/python/helloworld
``` ```
### Run a gRPC application ### Run a gRPC application
@ -77,13 +77,13 @@ From the `examples/python/helloworld` directory:
1. Run the server: 1. Run the server:
```sh ```sh
$ python greeter_server.py python greeter_server.py
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ python greeter_client.py python greeter_client.py
``` ```
Congratulations! You've just run a client-server application with gRPC. Congratulations! You've just run a client-server application with gRPC.
@ -151,7 +151,7 @@ service definition.
From the `examples/python/helloworld` directory, run: From the `examples/python/helloworld` directory, run:
```sh ```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 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: 1. Run the server:
```sh ```sh
$ python greeter_server.py python greeter_server.py
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ python greeter_client.py python greeter_client.py
``` ```
### What's next ### What's next

View File

@ -32,14 +32,14 @@ To download the example, clone the `grpc` repository by running the following
command: command:
```sh ```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
$ cd grpc cd grpc
``` ```
Then change your current directory to `examples/ruby/route_guide`: Then change your current directory to `examples/ruby/route_guide`:
```sh ```sh
$ cd examples/ruby/route_guide cd examples/ruby/route_guide
``` ```
You also should have the relevant tools installed to generate the server and 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. Once that's done, the following command can be used to generate the ruby code.
```sh ```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: Running this command regenerates the following files in the lib directory:
@ -388,19 +388,19 @@ streams operate completely independently.
Work from the example directory: Work from the example directory:
```sh ```sh
$ cd examples/ruby cd examples/ruby
``` ```
Build the client and server: Build the client and server:
```sh ```sh
$ gem install bundler && bundle install gem install bundler && bundle install
``` ```
Run the server: Run the server:
```sh ```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" %}} {{% 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: From a different terminal, run the client:
```sh ```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
``` ```

View File

@ -13,7 +13,7 @@ weight: 10
To install gRPC, run the following command: To install gRPC, run the following command:
```sh ```sh
$ gem install grpc gem install grpc
``` ```
#### gRPC tools #### gRPC tools
@ -29,7 +29,7 @@ tutorials and your own projects.
To install gRPC tools, run the following command: To install gRPC tools, run the following command:
```sh ```sh
$ gem install grpc-tools gem install grpc-tools
``` ```
### Download the example ### Download the example
@ -41,9 +41,9 @@ and other tutorials):
```sh ```sh
# Clone the repository to get the example code: # 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: # Navigate to the "hello, world" Ruby example:
$ cd grpc/examples/ruby cd grpc/examples/ruby
``` ```
### Run a gRPC application ### Run a gRPC application
@ -53,13 +53,13 @@ From the `examples/ruby` directory:
1. Run the server: 1. Run the server:
```sh ```sh
$ ruby greeter_server.rb ruby greeter_server.rb
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ ruby greeter_client.rb ruby greeter_client.rb
``` ```
Congratulations! You've just run a client-server application with gRPC. 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: service definition. From the `examples/ruby/` directory:
```sh ```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 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: 1. Run the server:
```sh ```sh
$ ruby greeter_server.rb ruby greeter_server.rb
``` ```
2. From another terminal, run the client: 2. From another terminal, run the client:
```sh ```sh
$ ruby greeter_client.rb ruby greeter_client.rb
``` ```
### What's next ### What's next

View File

@ -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: 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 ```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`: Then change your current directory to `grpc-java/examples/android`:
```sh ```sh
$ cd grpc-java/examples/android cd grpc-java/examples/android
``` ```
You also should have the relevant tools installed to generate the client You also should have the relevant tools installed to generate the client

View File

@ -18,7 +18,7 @@ weight: 10
the following environment variable: the following environment variable:
```sh ```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 - 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: the repo:
```sh ```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: 2. Change to the examples directory:
```sh ```sh
$ cd grpc-java/examples cd grpc-java/examples
``` ```
### Run the example ### Run the example
@ -52,20 +52,20 @@ The example code is part of the [grpc-java][] repo.
1. Compile the server: 1. Compile the server:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./build/install/examples/bin/hello-world-server ./build/install/examples/bin/hello-world-server
INFO: Server started, listening on 50051 INFO: Server started, listening on 50051
``` ```
3. From another terminal, build the client and install it on your device: 3. From another terminal, build the client and install it on your device:
```sh ```sh
$ (cd android/helloworld; ../../gradlew installDebug) (cd android/helloworld; ../../gradlew installDebug)
``` ```
4. Launch the client app from your device. 4. Launch the client app from your device.
@ -190,20 +190,20 @@ from the `examples` directory:
1. Compile the server: 1. Compile the server:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./build/install/examples/bin/hello-world-server ./build/install/examples/bin/hello-world-server
INFO: Server started, listening on 50051 INFO: Server started, listening on 50051
``` ```
3. From another terminal, build the client and install it on your device: 3. From another terminal, build the client and install it on your device:
```sh ```sh
$ (cd android/helloworld; ../../gradlew installDebug) (cd android/helloworld; ../../gradlew installDebug)
``` ```
4. Launch the client app from your device. 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: port forwarding using the `adb` command as follows:
```sh ```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 This sets up port forwarding from port `8080` on the device to port `50051` on

View File

@ -19,7 +19,7 @@ weight: 10
the following environment variable: the following environment variable:
```sh ```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 - 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: the repo:
```sh ```sh
$ git clone https://github.com/grpc/grpc-kotlin git clone https://github.com/grpc/grpc-kotlin
``` ```
2. Change to the examples directory: 2. Change to the examples directory:
```sh ```sh
$ cd grpc-kotlin/examples cd grpc-kotlin/examples
``` ```
### Run the example ### Run the example
@ -53,20 +53,20 @@ The example code is part of the [grpc-kotlin][] repo.
1. Compile the server: 1. Compile the server:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./server/build/install/server/bin/hello-world-server ./server/build/install/server/bin/hello-world-server
Server started, listening on 50051 Server started, listening on 50051
``` ```
3. From another terminal, build the client and install it on your device: 3. From another terminal, build the client and install it on your device:
```sh ```sh
$ ./gradlew :android:installDebug ./gradlew :android:installDebug
``` ```
4. Launch the client app from your device. 4. Launch the client app from your device.
@ -182,20 +182,20 @@ from the `examples` directory:
1. Compile the server: 1. Compile the server:
```sh ```sh
$ ./gradlew installDist ./gradlew installDist
``` ```
2. Run the server: 2. Run the server:
```sh ```sh
$ ./server/build/install/server/bin/hello-world-server ./server/build/install/server/bin/hello-world-server
Server started, listening on 50051 Server started, listening on 50051
``` ```
3. From another terminal, build the client and install it on your device: 3. From another terminal, build the client and install it on your device:
```sh ```sh
$ ./gradlew :android:installDebug ./gradlew :android:installDebug
``` ```
4. Launch the client app from your device. 4. Launch the client app from your device.

View File

@ -142,7 +142,7 @@ To generate the protobuf message classes from our `echo.proto`, run the
following command: following command:
```sh ```sh
$ protoc -I=$DIR echo.proto \ protoc -I=$DIR echo.proto \
--js_out=import_style=commonjs:$OUT_DIR --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: this from the repo's root directory:
```sh ```sh
$ cd grpc-web cd grpc-web
$ sudo make install-plugin sudo make install-plugin
``` ```
To generate the service client stub file, run this command: To generate the service client stub file, run this command:
```sh ```sh
$ protoc -I=$DIR echo.proto \ protoc -I=$DIR echo.proto \
--grpc-web_out=import_style=commonjs,mode=grpcwebtext:$OUT_DIR --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. into one single JS library that can be used in the browser.
```sh ```sh
$ npm install npm install
$ npx webpack client.js npx webpack client.js
``` ```
Now embed `dist/main.js` into your project and see it in action! Now embed `dist/main.js` into your project and see it in action!

View File

@ -20,13 +20,13 @@ The example code is part of the [grpc-web][] repo.
the repo: the repo:
```sh ```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: 2. Change to the repo's root directory:
```sh ```sh
$ cd grpc-web cd grpc-web
``` ```
### Run an Echo example from your browser! ### Run an Echo example from your browser!
@ -36,7 +36,7 @@ From the `grpc-web` directory:
1. Fetch required packages and tools: 1. Fetch required packages and tools:
```sh ```sh
$ docker-compose pull prereqs node-server envoy commonjs-client docker-compose pull prereqs node-server envoy commonjs-client
``` ```
{{% alert title="Note" color="info" %}} {{% 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: 2. Launch services as background processes:
```sh ```sh
$ docker-compose up -d node-server envoy commonjs-client docker-compose up -d node-server envoy commonjs-client
``` ```
3. From your browser: 3. From your browser:
@ -69,7 +69,7 @@ Once you are done, shutdown the services that you launched earlier by running
the following command: the following command:
```sh ```sh
$ docker-compose down docker-compose down
``` ```
### What is happening? ### What is happening?

View File

@ -32,15 +32,15 @@ Linux or macOS using the following commands.
- Linux, using `apt` or `apt-get`, for example: - Linux, using `apt` or `apt-get`, for example:
```sh ```sh
$ apt install -y protobuf-compiler apt install -y protobuf-compiler
$ protoc --version # Ensure compiler version is 3+ protoc --version # Ensure compiler version is 3+
``` ```
- MacOS, using [Homebrew][]: - MacOS, using [Homebrew][]:
```sh ```sh
$ brew install protobuf brew install protobuf
$ protoc --version # Ensure compiler version is 3+ protoc --version # Ensure compiler version is 3+
``` ```
<a name="binary-install"></a> <a name="binary-install"></a>
@ -56,22 +56,22 @@ binaries, follow these instructions:
as the following: as the following:
```sh ```sh
$ PB_REL="https://github.com/protocolbuffers/protobuf/releases" 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 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 2. Unzip the file under `$HOME/.local` or a directory of your choice. For
example: example:
```sh ```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 3. Update your environment's path variable to include the path to the
`protoc` executable. For example: `protoc` executable. For example:
```sh ```sh
$ export PATH="$PATH:$HOME/.local/bin" export PATH="$PATH:$HOME/.local/bin"
``` ```
### Other installation options ### Other installation options