mirror of https://github.com/grpc/grpc-java.git
Add build file and instructions to examples directory. Fixes #43
This commit is contained in:
parent
62f4399e26
commit
246e8b52bb
|
|
@ -0,0 +1,22 @@
|
|||
grpc Examples
|
||||
==============================================
|
||||
|
||||
In order to run the examples simply execute one of the gradle tasks `mathserver`, `mathclient`,
|
||||
`stockserver` or `stockclient`.
|
||||
|
||||
For example, say you want to play around with the math examples. First you want to start
|
||||
the server and then have the client connect to it and do some fun calculations.
|
||||
|
||||
Assuming you are in the grpc-java root folder you would first start the math server by running
|
||||
|
||||
```
|
||||
$ ./gradlew :grpc-examples:mathserver
|
||||
```
|
||||
|
||||
and in a different terminal window then run the client by typing
|
||||
|
||||
```
|
||||
$ ./gradlew :grpc-examples:mathclient
|
||||
```
|
||||
|
||||
That's it!
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
apply plugin: 'application'
|
||||
apply plugin: 'protobuf'
|
||||
|
||||
description = "grpc Examples"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath libraries.protobuf_plugin
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':grpc-core'),
|
||||
project(':grpc-netty'),
|
||||
project(':grpc-okhttp'),
|
||||
project(':grpc-stub')
|
||||
}
|
||||
|
||||
protobufCodeGenPlugins = ["java_plugin:$rootDir/compiler/build/binaries/java_pluginExecutable/java_plugin"]
|
||||
generateProto.dependsOn ':grpc-compiler:java_pluginExecutable'
|
||||
|
||||
task mathserver(type: JavaExec) {
|
||||
main = "io.grpc.examples.MathServer"
|
||||
description = "Executes the math server."
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
|
||||
task mathclient(type: JavaExec) {
|
||||
main = "io.grpc.examples.MathClient"
|
||||
description = "Executes the math client."
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
|
||||
task stockserver(type: JavaExec) {
|
||||
main = "io.grpc.examples.StockServer"
|
||||
description = "Executes the stock server."
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
|
||||
task stockclient(type: JavaExec) {
|
||||
main = "io.grpc.examples.StockClient"
|
||||
description = "Executes the stock client."
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
|
|
@ -32,13 +32,13 @@
|
|||
package io.grpc.examples;
|
||||
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import com.google.protos.io.grpc.examples.CalcGrpc;
|
||||
import com.google.protos.io.grpc.examples.CalcGrpc.CalcBlockingStub;
|
||||
import com.google.protos.io.grpc.examples.CalcGrpc.CalcStub;
|
||||
import com.google.protos.io.grpc.examples.Math.DivArgs;
|
||||
import com.google.protos.io.grpc.examples.Math.DivReply;
|
||||
import com.google.protos.io.grpc.examples.Math.FibArgs;
|
||||
import com.google.protos.io.grpc.examples.Math.Num;
|
||||
import io.grpc.examples.CalcGrpc;
|
||||
import io.grpc.examples.CalcGrpc.CalcBlockingStub;
|
||||
import io.grpc.examples.CalcGrpc.CalcStub;
|
||||
import io.grpc.examples.Math.DivArgs;
|
||||
import io.grpc.examples.Math.DivReply;
|
||||
import io.grpc.examples.Math.FibArgs;
|
||||
import io.grpc.examples.Math.Num;
|
||||
|
||||
import io.grpc.ChannelImpl;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@
|
|||
|
||||
package io.grpc.examples;
|
||||
|
||||
import com.google.protos.io.grpc.examples.CalcGrpc;
|
||||
import com.google.protos.io.grpc.examples.Math.DivArgs;
|
||||
import com.google.protos.io.grpc.examples.Math.DivReply;
|
||||
import com.google.protos.io.grpc.examples.Math.FibArgs;
|
||||
import com.google.protos.io.grpc.examples.Math.Num;
|
||||
import io.grpc.examples.CalcGrpc;
|
||||
import io.grpc.examples.Math.DivArgs;
|
||||
import io.grpc.examples.Math.DivReply;
|
||||
import io.grpc.examples.Math.FibArgs;
|
||||
import io.grpc.examples.Math.Num;
|
||||
|
||||
import io.grpc.ServerImpl;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@
|
|||
|
||||
package io.grpc.examples;
|
||||
|
||||
import com.google.protos.io.grpc.examples.StockGrpc;
|
||||
import com.google.protos.io.grpc.examples.StockGrpc.StockBlockingStub;
|
||||
import com.google.protos.io.grpc.examples.StockGrpc.StockStub;
|
||||
import com.google.protos.io.grpc.examples.StockOuterClass.StockReply;
|
||||
import com.google.protos.io.grpc.examples.StockOuterClass.StockRequest;
|
||||
import io.grpc.examples.StockGrpc;
|
||||
import io.grpc.examples.StockGrpc.StockBlockingStub;
|
||||
import io.grpc.examples.StockGrpc.StockStub;
|
||||
import io.grpc.examples.StockOuterClass.StockReply;
|
||||
import io.grpc.examples.StockOuterClass.StockRequest;
|
||||
|
||||
import io.grpc.ChannelImpl;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@
|
|||
|
||||
package io.grpc.examples;
|
||||
|
||||
import com.google.protos.io.grpc.examples.StockGrpc;
|
||||
import com.google.protos.io.grpc.examples.StockOuterClass.StockReply;
|
||||
import com.google.protos.io.grpc.examples.StockOuterClass.StockRequest;
|
||||
import io.grpc.examples.StockGrpc;
|
||||
import io.grpc.examples.StockOuterClass.StockReply;
|
||||
import io.grpc.examples.StockOuterClass.StockRequest;
|
||||
|
||||
import io.grpc.ServerImpl;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ include ":grpc-compiler"
|
|||
include ":grpc-integration-testing"
|
||||
include ":grpc-all"
|
||||
include ":grpc-benchmarks"
|
||||
include ":grpc-examples"
|
||||
|
||||
project(':grpc-core').projectDir = "$rootDir/core" as File
|
||||
project(':grpc-stub').projectDir = "$rootDir/stub" as File
|
||||
|
|
@ -20,3 +21,4 @@ project(':grpc-compiler').projectDir = "$rootDir/compiler" as File
|
|||
project(':grpc-integration-testing').projectDir = "$rootDir/integration-testing" as File
|
||||
project(':grpc-all').projectDir = "$rootDir/all" as File
|
||||
project(':grpc-benchmarks').projectDir = "$rootDir/benchmarks" as File
|
||||
project(':grpc-examples').projectDir = "$rootDir/examples" as File
|
||||
|
|
|
|||
Loading…
Reference in New Issue