mirror of https://github.com/grpc/grpc-java.git
Delete protobuf-nano
Nano was dropped from upstream protobuf. See gRFC L51
This commit is contained in:
parent
b6720c9fe6
commit
50b08eee3b
|
@ -1,6 +1,4 @@
|
||||||
TestService.java.txt binary
|
TestService.java.txt binary
|
||||||
TestServiceLite.java.txt binary
|
TestServiceLite.java.txt binary
|
||||||
TestServiceNano.java.txt binary
|
|
||||||
TestDeprecatedService.java.txt binary
|
TestDeprecatedService.java.txt binary
|
||||||
TestDeprecatedServiceLite.java.txt binary
|
TestDeprecatedServiceLite.java.txt binary
|
||||||
TestDeprecatedServiceNano.java.txt binary
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ would be used to create all `v1.7` tags (e.g. `v1.7.0`, `v1.7.1`).
|
||||||
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \
|
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$((MINOR+1)).0'\1/' \
|
||||||
"${VERSION_FILES[@]}"
|
"${VERSION_FILES[@]}"
|
||||||
$ sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$((MINOR+1)).0/ \
|
$ sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$((MINOR+1)).0/ \
|
||||||
compiler/src/test{,Lite,Nano}/golden/Test{,Deprecated}Service.java.txt
|
compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt
|
||||||
$ ./gradlew build
|
$ ./gradlew build
|
||||||
$ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle"
|
$ git commit -a -m "Start $MAJOR.$((MINOR+1)).0 development cycle"
|
||||||
```
|
```
|
||||||
|
@ -126,7 +126,7 @@ Tagging the Release
|
||||||
```bash
|
```bash
|
||||||
# Change version to remove -SNAPSHOT
|
# Change version to remove -SNAPSHOT
|
||||||
$ sed -i 's/-SNAPSHOT\(.*CURRENT_GRPC_VERSION\)/\1/' "${VERSION_FILES[@]}"
|
$ sed -i 's/-SNAPSHOT\(.*CURRENT_GRPC_VERSION\)/\1/' "${VERSION_FILES[@]}"
|
||||||
$ sed -i s/-SNAPSHOT// compiler/src/test{,Lite,Nano}/golden/Test{,Deprecated}Service.java.txt
|
$ sed -i s/-SNAPSHOT// compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt
|
||||||
$ ./gradlew build
|
$ ./gradlew build
|
||||||
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH"
|
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$PATCH"
|
||||||
$ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH"
|
$ git tag -a v$MAJOR.$MINOR.$PATCH -m "Version $MAJOR.$MINOR.$PATCH"
|
||||||
|
@ -139,7 +139,7 @@ Tagging the Release
|
||||||
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \
|
$ sed -i 's/[0-9]\+\.[0-9]\+\.[0-9]\+\(.*CURRENT_GRPC_VERSION\)/'$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT'\1/' \
|
||||||
"${VERSION_FILES[@]}"
|
"${VERSION_FILES[@]}"
|
||||||
$ sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT/ \
|
$ sed -i s/$MAJOR.$MINOR.$PATCH/$MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT/ \
|
||||||
compiler/src/test{,Lite,Nano}/golden/Test{,Deprecated}Service.java.txt
|
compiler/src/test{,Lite}/golden/Test{,Deprecated}Service.java.txt
|
||||||
$ ./gradlew build
|
$ ./gradlew build
|
||||||
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
|
$ git commit -a -m "Bump version to $MAJOR.$MINOR.$((PATCH+1))-SNAPSHOT"
|
||||||
```
|
```
|
||||||
|
|
|
@ -19,7 +19,6 @@ def subprojects = [
|
||||||
project(':grpc-okhttp'),
|
project(':grpc-okhttp'),
|
||||||
project(':grpc-protobuf'),
|
project(':grpc-protobuf'),
|
||||||
project(':grpc-protobuf-lite'),
|
project(':grpc-protobuf-lite'),
|
||||||
project(':grpc-protobuf-nano'),
|
|
||||||
project(':grpc-stub'),
|
project(':grpc-stub'),
|
||||||
project(':grpc-testing'),
|
project(':grpc-testing'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -111,7 +111,6 @@ subprojects {
|
||||||
guavaVersion = '26.0-android'
|
guavaVersion = '26.0-android'
|
||||||
protobufVersion = '3.7.1'
|
protobufVersion = '3.7.1'
|
||||||
protocVersion = protobufVersion
|
protocVersion = protobufVersion
|
||||||
protobufNanoVersion = '3.0.0-alpha-5'
|
|
||||||
opencensusVersion = '0.21.0'
|
opencensusVersion = '0.21.0'
|
||||||
|
|
||||||
configureProtoCompilation = {
|
configureProtoCompilation = {
|
||||||
|
@ -210,8 +209,6 @@ subprojects {
|
||||||
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
|
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
|
||||||
protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1",
|
protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1",
|
||||||
protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0",
|
protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0",
|
||||||
protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}",
|
|
||||||
protoc_nano: "com.google.protobuf:protoc:3.5.1-1",
|
|
||||||
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.8',
|
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.8',
|
||||||
protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
|
protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
|
||||||
lang: "org.apache.commons:commons-lang3:3.5",
|
lang: "org.apache.commons:commons-lang3:3.5",
|
||||||
|
@ -386,7 +383,6 @@ subprojects {
|
||||||
"grpc-stub",
|
"grpc-stub",
|
||||||
"grpc-protobuf",
|
"grpc-protobuf",
|
||||||
"grpc-protobuf-lite",
|
"grpc-protobuf-lite",
|
||||||
"grpc-protobuf-nano"
|
|
||||||
])) {
|
])) {
|
||||||
asNode().dependencies.'*'.findAll() { dep ->
|
asNode().dependencies.'*'.findAll() { dep ->
|
||||||
dep.artifactId.text() in ['grpc-api', 'grpc-core']
|
dep.artifactId.text() in ['grpc-api', 'grpc-core']
|
||||||
|
@ -461,7 +457,6 @@ def publicApiSubprojects = [
|
||||||
':grpc-okhttp',
|
':grpc-okhttp',
|
||||||
':grpc-protobuf',
|
':grpc-protobuf',
|
||||||
':grpc-protobuf-lite',
|
':grpc-protobuf-lite',
|
||||||
':grpc-protobuf-nano',
|
|
||||||
':grpc-stub',
|
':grpc-stub',
|
||||||
':grpc-testing',
|
':grpc-testing',
|
||||||
]
|
]
|
||||||
|
|
|
@ -42,11 +42,6 @@ To generate Java interfaces with protobuf lite:
|
||||||
$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
|
$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
|
||||||
--grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
|
--grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
|
||||||
```
|
```
|
||||||
To generate Java interfaces with protobuf nano:
|
|
||||||
```
|
|
||||||
$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
|
|
||||||
--grpc-java_out=nano:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installing the codegen to Maven local repository
|
## Installing the codegen to Maven local repository
|
||||||
This will compile a codegen and put it under your ``~/.m2/repository``. This
|
This will compile a codegen and put it under your ``~/.m2/repository``. This
|
||||||
|
|
|
@ -125,7 +125,6 @@ model {
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
testLiteCompile
|
testLiteCompile
|
||||||
testNanoCompile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -135,18 +134,12 @@ dependencies {
|
||||||
testLiteCompile project(':grpc-protobuf-lite'),
|
testLiteCompile project(':grpc-protobuf-lite'),
|
||||||
project(':grpc-stub'),
|
project(':grpc-stub'),
|
||||||
libraries.javax_annotation
|
libraries.javax_annotation
|
||||||
testNanoCompile project(':grpc-protobuf-nano'),
|
|
||||||
project(':grpc-stub'),
|
|
||||||
libraries.javax_annotation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
testLite {
|
testLite {
|
||||||
proto { setSrcDirs(['src/test/proto']) }
|
proto { setSrcDirs(['src/test/proto']) }
|
||||||
}
|
}
|
||||||
testNano {
|
|
||||||
proto { setSrcDirs(['src/test/proto']) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestJava {
|
compileTestJava {
|
||||||
|
@ -167,20 +160,12 @@ compileTestLiteJava {
|
||||||
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
|
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestNanoJava {
|
|
||||||
options.compilerArgs = compileTestJava.options.compilerArgs
|
|
||||||
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
|
|
||||||
}
|
|
||||||
|
|
||||||
protobuf {
|
protobuf {
|
||||||
protoc {
|
protoc {
|
||||||
if (project.hasProperty('protoc')) {
|
if (project.hasProperty('protoc')) {
|
||||||
path = project.protoc
|
path = project.protoc
|
||||||
} else {
|
} else {
|
||||||
// Since nano is removed from newer versions of protoc, use an older version for the
|
artifact = "com.google.protobuf:protoc:${protocVersion}"
|
||||||
// while. This means we won't be able to test any descriptor.proto additions, but that
|
|
||||||
// should be fine for a while.
|
|
||||||
artifact = libraries.protoc_nano
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugins {
|
plugins {
|
||||||
|
@ -206,20 +191,9 @@ protobuf {
|
||||||
grpc { option 'lite' }
|
grpc { option 'lite' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ofSourceSet('testNano').each { task ->
|
|
||||||
task.builtins {
|
|
||||||
remove java
|
|
||||||
javanano { option 'ignore_services=true' }
|
|
||||||
}
|
|
||||||
task.plugins { grpc { option 'nano' } }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkstyleTestNano {
|
|
||||||
source = fileTree(dir: "src/testNano", include: "**/*.java")
|
|
||||||
}
|
|
||||||
|
|
||||||
println "*** Building codegen requires Protobuf version ${protocVersion}"
|
println "*** Building codegen requires Protobuf version ${protocVersion}"
|
||||||
println "*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin"
|
println "*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin"
|
||||||
|
|
||||||
|
@ -320,13 +294,9 @@ def configureTestTask(Task task, String dep, String extraPackage, String service
|
||||||
|
|
||||||
task testGolden(type: Exec)
|
task testGolden(type: Exec)
|
||||||
task testLiteGolden(type: Exec)
|
task testLiteGolden(type: Exec)
|
||||||
task testNanoGolden(type: Exec)
|
|
||||||
task testDeprecatedGolden(type: Exec)
|
task testDeprecatedGolden(type: Exec)
|
||||||
task testDeprecatedLiteGolden(type: Exec)
|
task testDeprecatedLiteGolden(type: Exec)
|
||||||
task testDeprecatedNanoGolden(type: Exec)
|
|
||||||
configureTestTask(testGolden, '', '', 'TestService')
|
configureTestTask(testGolden, '', '', 'TestService')
|
||||||
configureTestTask(testLiteGolden, 'Lite', '', 'TestService')
|
configureTestTask(testLiteGolden, 'Lite', '', 'TestService')
|
||||||
configureTestTask(testNanoGolden, 'Nano', '/nano', 'TestService')
|
|
||||||
configureTestTask(testDeprecatedGolden, '', '', 'TestDeprecatedService')
|
configureTestTask(testDeprecatedGolden, '', '', 'TestDeprecatedService')
|
||||||
configureTestTask(testDeprecatedLiteGolden, 'Lite', '', 'TestDeprecatedService')
|
configureTestTask(testDeprecatedLiteGolden, 'Lite', '', 'TestDeprecatedService')
|
||||||
configureTestTask(testDeprecatedNanoGolden, 'Nano', '/nano', 'TestDeprecatedService')
|
|
||||||
|
|
|
@ -149,22 +149,8 @@ static inline bool ShouldGenerateAsLite(const Descriptor* desc) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string MessageFullJavaName(bool nano, const Descriptor* desc) {
|
static inline string MessageFullJavaName(const Descriptor* desc) {
|
||||||
string name = google::protobuf::compiler::java::ClassName(desc);
|
return google::protobuf::compiler::java::ClassName(desc);
|
||||||
if (nano && !ShouldGenerateAsLite(desc)) {
|
|
||||||
// XXX: Add "nano" to the original package
|
|
||||||
// (https://github.com/grpc/grpc-java/issues/900)
|
|
||||||
if (isupper(name[0])) {
|
|
||||||
// No java package specified.
|
|
||||||
return "nano." + name;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < name.size(); ++i) {
|
|
||||||
if ((name[i] == '.') && (i < (name.size() - 1)) && isupper(name[i + 1])) {
|
|
||||||
return name.substr(0, i + 1) + "nano." + name.substr(i + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
|
// TODO(nmittler): Remove once protobuf includes javadoc methods in distribution.
|
||||||
|
@ -379,10 +365,8 @@ static void PrintMethodFields(
|
||||||
(*vars)["arg_in_id"] = to_string(2 * i);
|
(*vars)["arg_in_id"] = to_string(2 * i);
|
||||||
(*vars)["arg_out_id"] = to_string(2 * i + 1);
|
(*vars)["arg_out_id"] = to_string(2 * i + 1);
|
||||||
(*vars)["method_name"] = method->name();
|
(*vars)["method_name"] = method->name();
|
||||||
(*vars)["input_type"] = MessageFullJavaName(flavor == ProtoFlavor::NANO,
|
(*vars)["input_type"] = MessageFullJavaName(method->input_type());
|
||||||
method->input_type());
|
(*vars)["output_type"] = MessageFullJavaName(method->output_type());
|
||||||
(*vars)["output_type"] = MessageFullJavaName(flavor == ProtoFlavor::NANO,
|
|
||||||
method->output_type());
|
|
||||||
(*vars)["method_field_name"] = MethodPropertiesFieldName(method);
|
(*vars)["method_field_name"] = MethodPropertiesFieldName(method);
|
||||||
(*vars)["method_new_field_name"] = MethodPropertiesGetterName(method);
|
(*vars)["method_new_field_name"] = MethodPropertiesGetterName(method);
|
||||||
(*vars)["method_method_name"] = MethodPropertiesGetterName(method);
|
(*vars)["method_method_name"] = MethodPropertiesGetterName(method);
|
||||||
|
@ -402,170 +386,53 @@ static void PrintMethodFields(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flavor == ProtoFlavor::NANO) {
|
if (flavor == ProtoFlavor::LITE) {
|
||||||
// TODO(zsurocking): we're creating two NanoFactories for each method right now.
|
(*vars)["ProtoUtils"] = "io.grpc.protobuf.lite.ProtoLiteUtils";
|
||||||
// We could instead create static NanoFactories and reuse them if some methods
|
|
||||||
// share the same request or response messages.
|
|
||||||
if (!ShouldGenerateAsLite(method->input_type())) {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
"private static final int ARG_IN_$method_field_name$ = $arg_in_id$;\n");
|
|
||||||
}
|
|
||||||
if (!ShouldGenerateAsLite(method->output_type())) {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
"private static final int ARG_OUT_$method_field_name$ = $arg_out_id$;\n");
|
|
||||||
}
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
"private static volatile $MethodDescriptor$<$input_type$,\n"
|
|
||||||
" $output_type$> $method_new_field_name$;\n"
|
|
||||||
"\n"
|
|
||||||
"public static $MethodDescriptor$<$input_type$,\n"
|
|
||||||
" $output_type$> $method_method_name$() {\n"
|
|
||||||
" $MethodDescriptor$<$input_type$, $output_type$> $method_new_field_name$;\n"
|
|
||||||
" if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
|
|
||||||
" synchronized ($service_class_name$.class) {\n"
|
|
||||||
" if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
|
|
||||||
" $service_class_name$.$method_new_field_name$ = $method_new_field_name$ = \n"
|
|
||||||
" $MethodDescriptor$.<$input_type$, $output_type$>newBuilder()\n"
|
|
||||||
" .setType($MethodType$.$method_type$)\n"
|
|
||||||
" .setFullMethodName(generateFullMethodName(\n"
|
|
||||||
" \"$Package$$service_name$\", \"$method_name$\"))\n"
|
|
||||||
" .setSampledToLocalTracing(true)\n");
|
|
||||||
|
|
||||||
(*vars)["ProtoLiteUtils"] = "io.grpc.protobuf.lite.ProtoLiteUtils";
|
|
||||||
|
|
||||||
if (ShouldGenerateAsLite(method->input_type())) {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .setRequestMarshaller($ProtoLiteUtils$.marshaller(\n"
|
|
||||||
" $input_type$.getDefaultInstance()))\n");
|
|
||||||
} else {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .setRequestMarshaller($NanoUtils$.<$input_type$>marshaller(\n"
|
|
||||||
" new NanoFactory<$input_type$>(ARG_IN_$method_field_name$)))\n");
|
|
||||||
}
|
|
||||||
if (ShouldGenerateAsLite(method->output_type())) {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .setResponseMarshaller($ProtoLiteUtils$.marshaller(\n"
|
|
||||||
" $output_type$.getDefaultInstance()))\n");
|
|
||||||
} else {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .setResponseMarshaller($NanoUtils$.<$output_type$>marshaller(\n"
|
|
||||||
" new NanoFactory<$output_type$>(ARG_OUT_$method_field_name$)))\n");
|
|
||||||
}
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .build();\n"
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" return $method_new_field_name$;\n"
|
|
||||||
"}\n"
|
|
||||||
"\n");
|
|
||||||
} else {
|
} else {
|
||||||
if (flavor == ProtoFlavor::LITE) {
|
(*vars)["ProtoUtils"] = "io.grpc.protobuf.ProtoUtils";
|
||||||
(*vars)["ProtoUtils"] = "io.grpc.protobuf.lite.ProtoLiteUtils";
|
|
||||||
} else {
|
|
||||||
(*vars)["ProtoUtils"] = "io.grpc.protobuf.ProtoUtils";
|
|
||||||
}
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
"private static volatile $MethodDescriptor$<$input_type$,\n"
|
|
||||||
" $output_type$> $method_new_field_name$;\n"
|
|
||||||
"\n"
|
|
||||||
"@$RpcMethod$(\n"
|
|
||||||
" fullMethodName = SERVICE_NAME + '/' + \"$method_name$\",\n"
|
|
||||||
" requestType = $input_type$.class,\n"
|
|
||||||
" responseType = $output_type$.class,\n"
|
|
||||||
" methodType = $MethodType$.$method_type$)\n"
|
|
||||||
"public static $MethodDescriptor$<$input_type$,\n"
|
|
||||||
" $output_type$> $method_method_name$() {\n"
|
|
||||||
" $MethodDescriptor$<$input_type$, $output_type$> $method_new_field_name$;\n"
|
|
||||||
" if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
|
|
||||||
" synchronized ($service_class_name$.class) {\n"
|
|
||||||
" if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
|
|
||||||
" $service_class_name$.$method_new_field_name$ = $method_new_field_name$ = \n"
|
|
||||||
" $MethodDescriptor$.<$input_type$, $output_type$>newBuilder()\n"
|
|
||||||
" .setType($MethodType$.$method_type$)\n"
|
|
||||||
" .setFullMethodName(generateFullMethodName(\n"
|
|
||||||
" \"$Package$$service_name$\", \"$method_name$\"))\n"
|
|
||||||
" .setSampledToLocalTracing(true)\n"
|
|
||||||
" .setRequestMarshaller($ProtoUtils$.marshaller(\n"
|
|
||||||
" $input_type$.getDefaultInstance()))\n"
|
|
||||||
" .setResponseMarshaller($ProtoUtils$.marshaller(\n"
|
|
||||||
" $output_type$.getDefaultInstance()))\n");
|
|
||||||
|
|
||||||
(*vars)["proto_method_descriptor_supplier"] = service->name() + "MethodDescriptorSupplier";
|
|
||||||
if (flavor == ProtoFlavor::NORMAL) {
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .setSchemaDescriptor(new $proto_method_descriptor_supplier$(\"$method_name$\"))\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
p->Print(
|
|
||||||
*vars,
|
|
||||||
" .build();\n");
|
|
||||||
p->Print(*vars,
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" }\n"
|
|
||||||
" return $method_new_field_name$;\n"
|
|
||||||
"}\n"
|
|
||||||
"\n");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (flavor == ProtoFlavor::NANO) {
|
|
||||||
p->Print(
|
p->Print(
|
||||||
*vars,
|
*vars,
|
||||||
"private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano>\n"
|
"private static volatile $MethodDescriptor$<$input_type$,\n"
|
||||||
" implements io.grpc.protobuf.nano.MessageNanoFactory<T> {\n"
|
" $output_type$> $method_new_field_name$;\n"
|
||||||
" private final int id;\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
" NanoFactory(int id) {\n"
|
"@$RpcMethod$(\n"
|
||||||
" this.id = id;\n"
|
" fullMethodName = SERVICE_NAME + '/' + \"$method_name$\",\n"
|
||||||
" }\n"
|
" requestType = $input_type$.class,\n"
|
||||||
"\n"
|
" responseType = $output_type$.class,\n"
|
||||||
" @$Override$\n"
|
" methodType = $MethodType$.$method_type$)\n"
|
||||||
" public T newInstance() {\n"
|
"public static $MethodDescriptor$<$input_type$,\n"
|
||||||
" Object o;\n"
|
" $output_type$> $method_method_name$() {\n"
|
||||||
" switch (id) {\n");
|
" $MethodDescriptor$<$input_type$, $output_type$> $method_new_field_name$;\n"
|
||||||
bool generate_nano = true;
|
" if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
|
||||||
for (int i = 0; i < service->method_count(); ++i) {
|
" synchronized ($service_class_name$.class) {\n"
|
||||||
const MethodDescriptor* method = service->method(i);
|
" if (($method_new_field_name$ = $service_class_name$.$method_new_field_name$) == null) {\n"
|
||||||
(*vars)["input_type"] = MessageFullJavaName(generate_nano,
|
" $service_class_name$.$method_new_field_name$ = $method_new_field_name$ = \n"
|
||||||
method->input_type());
|
" $MethodDescriptor$.<$input_type$, $output_type$>newBuilder()\n"
|
||||||
(*vars)["output_type"] = MessageFullJavaName(generate_nano,
|
" .setType($MethodType$.$method_type$)\n"
|
||||||
method->output_type());
|
" .setFullMethodName(generateFullMethodName(\n"
|
||||||
(*vars)["method_field_name"] = MethodPropertiesFieldName(method);
|
" \"$Package$$service_name$\", \"$method_name$\"))\n"
|
||||||
if (!ShouldGenerateAsLite(method->input_type())) {
|
" .setSampledToLocalTracing(true)\n"
|
||||||
p->Print(
|
" .setRequestMarshaller($ProtoUtils$.marshaller(\n"
|
||||||
*vars,
|
" $input_type$.getDefaultInstance()))\n"
|
||||||
" case ARG_IN_$method_field_name$:\n"
|
" .setResponseMarshaller($ProtoUtils$.marshaller(\n"
|
||||||
" o = new $input_type$();\n"
|
" $output_type$.getDefaultInstance()))\n");
|
||||||
" break;\n");
|
|
||||||
}
|
(*vars)["proto_method_descriptor_supplier"] = service->name() + "MethodDescriptorSupplier";
|
||||||
if (!ShouldGenerateAsLite(method->output_type())) {
|
if (flavor == ProtoFlavor::NORMAL) {
|
||||||
p->Print(
|
p->Print(
|
||||||
*vars,
|
*vars,
|
||||||
" case ARG_OUT_$method_field_name$:\n"
|
" .setSchemaDescriptor(new $proto_method_descriptor_supplier$(\"$method_name$\"))\n");
|
||||||
" o = new $output_type$();\n"
|
|
||||||
" break;\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p->Print(
|
p->Print(
|
||||||
" default:\n"
|
*vars,
|
||||||
" throw new AssertionError();\n"
|
" .build();\n");
|
||||||
" }\n"
|
p->Print(*vars,
|
||||||
" @java.lang.SuppressWarnings(\"unchecked\")\n"
|
" }\n"
|
||||||
" T t = (T) o;\n"
|
" }\n"
|
||||||
" return t;\n"
|
" }\n"
|
||||||
" }\n"
|
" return $method_new_field_name$;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n");
|
"\n");
|
||||||
}
|
}
|
||||||
|
@ -590,14 +457,13 @@ enum CallType {
|
||||||
|
|
||||||
static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
|
static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
|
||||||
std::map<string, string>* vars,
|
std::map<string, string>* vars,
|
||||||
Printer* p,
|
Printer* p);
|
||||||
bool generate_nano);
|
|
||||||
|
|
||||||
// Prints a client interface or implementation class, or a server interface.
|
// Prints a client interface or implementation class, or a server interface.
|
||||||
static void PrintStub(
|
static void PrintStub(
|
||||||
const ServiceDescriptor* service,
|
const ServiceDescriptor* service,
|
||||||
std::map<string, string>* vars,
|
std::map<string, string>* vars,
|
||||||
Printer* p, StubType type, bool generate_nano) {
|
Printer* p, StubType type) {
|
||||||
const string service_name = service->name();
|
const string service_name = service->name();
|
||||||
(*vars)["service_name"] = service_name;
|
(*vars)["service_name"] = service_name;
|
||||||
(*vars)["abstract_name"] = service_name + "ImplBase";
|
(*vars)["abstract_name"] = service_name + "ImplBase";
|
||||||
|
@ -694,10 +560,8 @@ static void PrintStub(
|
||||||
// RPC methods
|
// RPC methods
|
||||||
for (int i = 0; i < service->method_count(); ++i) {
|
for (int i = 0; i < service->method_count(); ++i) {
|
||||||
const MethodDescriptor* method = service->method(i);
|
const MethodDescriptor* method = service->method(i);
|
||||||
(*vars)["input_type"] = MessageFullJavaName(generate_nano,
|
(*vars)["input_type"] = MessageFullJavaName(method->input_type());
|
||||||
method->input_type());
|
(*vars)["output_type"] = MessageFullJavaName(method->output_type());
|
||||||
(*vars)["output_type"] = MessageFullJavaName(generate_nano,
|
|
||||||
method->output_type());
|
|
||||||
(*vars)["lower_method_name"] = LowerMethodName(method);
|
(*vars)["lower_method_name"] = LowerMethodName(method);
|
||||||
(*vars)["method_method_name"] = MethodPropertiesGetterName(method);
|
(*vars)["method_method_name"] = MethodPropertiesGetterName(method);
|
||||||
bool client_streaming = method->client_streaming();
|
bool client_streaming = method->client_streaming();
|
||||||
|
@ -858,7 +722,7 @@ static void PrintStub(
|
||||||
*vars,
|
*vars,
|
||||||
"@$Override$ public final $ServerServiceDefinition$ bindService() {\n");
|
"@$Override$ public final $ServerServiceDefinition$ bindService() {\n");
|
||||||
(*vars)["instance"] = "this";
|
(*vars)["instance"] = "this";
|
||||||
PrintBindServiceMethodBody(service, vars, p, generate_nano);
|
PrintBindServiceMethodBody(service, vars, p);
|
||||||
p->Print("}\n");
|
p->Print("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -876,8 +740,7 @@ static bool CompareMethodClientStreaming(const MethodDescriptor* method1,
|
||||||
// on Android.
|
// on Android.
|
||||||
static void PrintMethodHandlerClass(const ServiceDescriptor* service,
|
static void PrintMethodHandlerClass(const ServiceDescriptor* service,
|
||||||
std::map<string, string>* vars,
|
std::map<string, string>* vars,
|
||||||
Printer* p,
|
Printer* p) {
|
||||||
bool generate_nano) {
|
|
||||||
// Sort method ids based on client_streaming() so switch tables are compact.
|
// Sort method ids based on client_streaming() so switch tables are compact.
|
||||||
std::vector<const MethodDescriptor*> sorted_methods(service->method_count());
|
std::vector<const MethodDescriptor*> sorted_methods(service->method_count());
|
||||||
for (int i = 0; i < service->method_count(); ++i) {
|
for (int i = 0; i < service->method_count(); ++i) {
|
||||||
|
@ -926,10 +789,8 @@ static void PrintMethodHandlerClass(const ServiceDescriptor* service,
|
||||||
}
|
}
|
||||||
(*vars)["method_id_name"] = MethodIdFieldName(method);
|
(*vars)["method_id_name"] = MethodIdFieldName(method);
|
||||||
(*vars)["lower_method_name"] = LowerMethodName(method);
|
(*vars)["lower_method_name"] = LowerMethodName(method);
|
||||||
(*vars)["input_type"] = MessageFullJavaName(generate_nano,
|
(*vars)["input_type"] = MessageFullJavaName(method->input_type());
|
||||||
method->input_type());
|
(*vars)["output_type"] = MessageFullJavaName(method->output_type());
|
||||||
(*vars)["output_type"] = MessageFullJavaName(generate_nano,
|
|
||||||
method->output_type());
|
|
||||||
p->Print(
|
p->Print(
|
||||||
*vars,
|
*vars,
|
||||||
"case $method_id_name$:\n"
|
"case $method_id_name$:\n"
|
||||||
|
@ -962,10 +823,8 @@ static void PrintMethodHandlerClass(const ServiceDescriptor* service,
|
||||||
}
|
}
|
||||||
(*vars)["method_id_name"] = MethodIdFieldName(method);
|
(*vars)["method_id_name"] = MethodIdFieldName(method);
|
||||||
(*vars)["lower_method_name"] = LowerMethodName(method);
|
(*vars)["lower_method_name"] = LowerMethodName(method);
|
||||||
(*vars)["input_type"] = MessageFullJavaName(generate_nano,
|
(*vars)["input_type"] = MessageFullJavaName(method->input_type());
|
||||||
method->input_type());
|
(*vars)["output_type"] = MessageFullJavaName(method->output_type());
|
||||||
(*vars)["output_type"] = MessageFullJavaName(generate_nano,
|
|
||||||
method->output_type());
|
|
||||||
p->Print(
|
p->Print(
|
||||||
*vars,
|
*vars,
|
||||||
"case $method_id_name$:\n"
|
"case $method_id_name$:\n"
|
||||||
|
@ -1088,8 +947,7 @@ static void PrintGetServiceDescriptorMethod(const ServiceDescriptor* service,
|
||||||
|
|
||||||
static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
|
static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
|
||||||
std::map<string, string>* vars,
|
std::map<string, string>* vars,
|
||||||
Printer* p,
|
Printer* p) {
|
||||||
bool generate_nano) {
|
|
||||||
(*vars)["service_name"] = service->name();
|
(*vars)["service_name"] = service->name();
|
||||||
p->Indent();
|
p->Indent();
|
||||||
p->Print(*vars,
|
p->Print(*vars,
|
||||||
|
@ -1101,10 +959,8 @@ static void PrintBindServiceMethodBody(const ServiceDescriptor* service,
|
||||||
const MethodDescriptor* method = service->method(i);
|
const MethodDescriptor* method = service->method(i);
|
||||||
(*vars)["lower_method_name"] = LowerMethodName(method);
|
(*vars)["lower_method_name"] = LowerMethodName(method);
|
||||||
(*vars)["method_method_name"] = MethodPropertiesGetterName(method);
|
(*vars)["method_method_name"] = MethodPropertiesGetterName(method);
|
||||||
(*vars)["input_type"] = MessageFullJavaName(generate_nano,
|
(*vars)["input_type"] = MessageFullJavaName(method->input_type());
|
||||||
method->input_type());
|
(*vars)["output_type"] = MessageFullJavaName(method->output_type());
|
||||||
(*vars)["output_type"] = MessageFullJavaName(generate_nano,
|
|
||||||
method->output_type());
|
|
||||||
(*vars)["method_id_name"] = MethodIdFieldName(method);
|
(*vars)["method_id_name"] = MethodIdFieldName(method);
|
||||||
bool client_streaming = method->client_streaming();
|
bool client_streaming = method->client_streaming();
|
||||||
bool server_streaming = method->server_streaming();
|
bool server_streaming = method->server_streaming();
|
||||||
|
@ -1224,19 +1080,18 @@ static void PrintService(const ServiceDescriptor* service,
|
||||||
p->Outdent();
|
p->Outdent();
|
||||||
p->Print("}\n\n");
|
p->Print("}\n\n");
|
||||||
|
|
||||||
bool generate_nano = flavor == ProtoFlavor::NANO;
|
PrintStub(service, vars, p, ABSTRACT_CLASS);
|
||||||
PrintStub(service, vars, p, ABSTRACT_CLASS, generate_nano);
|
PrintStub(service, vars, p, ASYNC_CLIENT_IMPL);
|
||||||
PrintStub(service, vars, p, ASYNC_CLIENT_IMPL, generate_nano);
|
PrintStub(service, vars, p, BLOCKING_CLIENT_IMPL);
|
||||||
PrintStub(service, vars, p, BLOCKING_CLIENT_IMPL, generate_nano);
|
PrintStub(service, vars, p, FUTURE_CLIENT_IMPL);
|
||||||
PrintStub(service, vars, p, FUTURE_CLIENT_IMPL, generate_nano);
|
|
||||||
|
|
||||||
PrintMethodHandlerClass(service, vars, p, generate_nano);
|
PrintMethodHandlerClass(service, vars, p);
|
||||||
PrintGetServiceDescriptorMethod(service, vars, p, flavor);
|
PrintGetServiceDescriptorMethod(service, vars, p, flavor);
|
||||||
p->Outdent();
|
p->Outdent();
|
||||||
p->Print("}\n");
|
p->Print("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintImports(Printer* p, bool generate_nano) {
|
void PrintImports(Printer* p) {
|
||||||
p->Print(
|
p->Print(
|
||||||
"import static "
|
"import static "
|
||||||
"io.grpc.MethodDescriptor.generateFullMethodName;\n"
|
"io.grpc.MethodDescriptor.generateFullMethodName;\n"
|
||||||
|
@ -1266,9 +1121,6 @@ void PrintImports(Printer* p, bool generate_nano) {
|
||||||
"io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;\n"
|
"io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;\n"
|
||||||
"import static "
|
"import static "
|
||||||
"io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;\n\n");
|
"io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;\n\n");
|
||||||
if (generate_nano) {
|
|
||||||
p->Print("import java.io.IOException;\n\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateService(const ServiceDescriptor* service,
|
void GenerateService(const ServiceDescriptor* service,
|
||||||
|
@ -1300,7 +1152,6 @@ void GenerateService(const ServiceDescriptor* service,
|
||||||
vars["AbstractStub"] = "io.grpc.stub.AbstractStub";
|
vars["AbstractStub"] = "io.grpc.stub.AbstractStub";
|
||||||
vars["RpcMethod"] = "io.grpc.stub.annotations.RpcMethod";
|
vars["RpcMethod"] = "io.grpc.stub.annotations.RpcMethod";
|
||||||
vars["MethodDescriptor"] = "io.grpc.MethodDescriptor";
|
vars["MethodDescriptor"] = "io.grpc.MethodDescriptor";
|
||||||
vars["NanoUtils"] = "io.grpc.protobuf.nano.NanoUtils";
|
|
||||||
vars["StreamObserver"] = "io.grpc.stub.StreamObserver";
|
vars["StreamObserver"] = "io.grpc.stub.StreamObserver";
|
||||||
vars["Iterator"] = "java.util.Iterator";
|
vars["Iterator"] = "java.util.Iterator";
|
||||||
vars["Generated"] = "javax.annotation.Generated";
|
vars["Generated"] = "javax.annotation.Generated";
|
||||||
|
@ -1308,14 +1159,13 @@ void GenerateService(const ServiceDescriptor* service,
|
||||||
"com.google.common.util.concurrent.ListenableFuture";
|
"com.google.common.util.concurrent.ListenableFuture";
|
||||||
|
|
||||||
Printer printer(out, '$');
|
Printer printer(out, '$');
|
||||||
string package_name = ServiceJavaPackage(service->file(),
|
string package_name = ServiceJavaPackage(service->file());
|
||||||
flavor == ProtoFlavor::NANO);
|
|
||||||
if (!package_name.empty()) {
|
if (!package_name.empty()) {
|
||||||
printer.Print(
|
printer.Print(
|
||||||
"package $package_name$;\n\n",
|
"package $package_name$;\n\n",
|
||||||
"package_name", package_name);
|
"package_name", package_name);
|
||||||
}
|
}
|
||||||
PrintImports(&printer, flavor == ProtoFlavor::NANO);
|
PrintImports(&printer);
|
||||||
|
|
||||||
// Package string is used to fully qualify method names.
|
// Package string is used to fully qualify method names.
|
||||||
vars["Package"] = service->file()->package();
|
vars["Package"] = service->file()->package();
|
||||||
|
@ -1325,7 +1175,7 @@ void GenerateService(const ServiceDescriptor* service,
|
||||||
PrintService(service, &vars, &printer, flavor, disable_version);
|
PrintService(service, &vars, &printer, flavor, disable_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
string ServiceJavaPackage(const FileDescriptor* file, bool nano) {
|
string ServiceJavaPackage(const FileDescriptor* file) {
|
||||||
string result = google::protobuf::compiler::java::ClassName(file);
|
string result = google::protobuf::compiler::java::ClassName(file);
|
||||||
size_t last_dot_pos = result.find_last_of('.');
|
size_t last_dot_pos = result.find_last_of('.');
|
||||||
if (last_dot_pos != string::npos) {
|
if (last_dot_pos != string::npos) {
|
||||||
|
@ -1333,12 +1183,6 @@ string ServiceJavaPackage(const FileDescriptor* file, bool nano) {
|
||||||
} else {
|
} else {
|
||||||
result = "";
|
result = "";
|
||||||
}
|
}
|
||||||
if (nano) {
|
|
||||||
if (!result.empty()) {
|
|
||||||
result += ".";
|
|
||||||
}
|
|
||||||
result += "nano";
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,11 @@ using namespace std;
|
||||||
namespace java_grpc_generator {
|
namespace java_grpc_generator {
|
||||||
|
|
||||||
enum ProtoFlavor {
|
enum ProtoFlavor {
|
||||||
NORMAL, LITE, NANO
|
NORMAL, LITE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the package name of the gRPC services defined in the given file.
|
// Returns the package name of the gRPC services defined in the given file.
|
||||||
string ServiceJavaPackage(const google::protobuf::FileDescriptor* file, bool nano);
|
string ServiceJavaPackage(const google::protobuf::FileDescriptor* file);
|
||||||
|
|
||||||
// Returns the name of the outer class that wraps in all the generated code for
|
// Returns the name of the outer class that wraps in all the generated code for
|
||||||
// the given service.
|
// the given service.
|
||||||
|
|
|
@ -39,17 +39,14 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
|
||||||
|
|
||||||
bool disable_version = false;
|
bool disable_version = false;
|
||||||
for (size_t i = 0; i < options.size(); i++) {
|
for (size_t i = 0; i < options.size(); i++) {
|
||||||
if (options[i].first == "nano") {
|
if (options[i].first == "lite") {
|
||||||
flavor = java_grpc_generator::ProtoFlavor::NANO;
|
|
||||||
} else if (options[i].first == "lite") {
|
|
||||||
flavor = java_grpc_generator::ProtoFlavor::LITE;
|
flavor = java_grpc_generator::ProtoFlavor::LITE;
|
||||||
} else if (options[i].first == "noversion") {
|
} else if (options[i].first == "noversion") {
|
||||||
disable_version = true;
|
disable_version = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string package_name = java_grpc_generator::ServiceJavaPackage(
|
string package_name = java_grpc_generator::ServiceJavaPackage(file);
|
||||||
file, flavor == java_grpc_generator::ProtoFlavor::NANO);
|
|
||||||
string package_filename = JavaPackageToDir(package_name);
|
string package_filename = JavaPackageToDir(package_name);
|
||||||
for (int i = 0; i < file->service_count(); ++i) {
|
for (int i = 0; i < file->service_count(); ++i) {
|
||||||
const google::protobuf::ServiceDescriptor* service = file->service(i);
|
const google::protobuf::ServiceDescriptor* service = file->service(i);
|
||||||
|
|
|
@ -1,305 +0,0 @@
|
||||||
package io.grpc.testing.compiler.nano;
|
|
||||||
|
|
||||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.futureUnaryCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@javax.annotation.Generated(
|
|
||||||
value = "by gRPC proto compiler (version 1.22.0-SNAPSHOT)",
|
|
||||||
comments = "Source: grpc/testing/compiler/test.proto")
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public final class TestDeprecatedServiceGrpc {
|
|
||||||
|
|
||||||
private TestDeprecatedServiceGrpc() {}
|
|
||||||
|
|
||||||
public static final String SERVICE_NAME = "grpc.testing.compiler.TestDeprecatedService";
|
|
||||||
|
|
||||||
// Static method descriptors that strictly reflect the proto.
|
|
||||||
private static final int ARG_IN_METHOD_DEPRECATED_METHOD = 0;
|
|
||||||
private static final int ARG_OUT_METHOD_DEPRECATED_METHOD = 1;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleResponse> getDeprecatedMethodMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleResponse> getDeprecatedMethodMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse> getDeprecatedMethodMethod;
|
|
||||||
if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
|
|
||||||
synchronized (TestDeprecatedServiceGrpc.class) {
|
|
||||||
if ((getDeprecatedMethodMethod = TestDeprecatedServiceGrpc.getDeprecatedMethodMethod) == null) {
|
|
||||||
TestDeprecatedServiceGrpc.getDeprecatedMethodMethod = getDeprecatedMethodMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestDeprecatedService", "DeprecatedMethod"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleRequest>(ARG_IN_METHOD_DEPRECATED_METHOD)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleResponse>(ARG_OUT_METHOD_DEPRECATED_METHOD)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getDeprecatedMethodMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano>
|
|
||||||
implements io.grpc.protobuf.nano.MessageNanoFactory<T> {
|
|
||||||
private final int id;
|
|
||||||
|
|
||||||
NanoFactory(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
public T newInstance() {
|
|
||||||
Object o;
|
|
||||||
switch (id) {
|
|
||||||
case ARG_IN_METHOD_DEPRECATED_METHOD:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.SimpleRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_DEPRECATED_METHOD:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.SimpleResponse();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
T t = (T) o;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new async stub that supports all call types for the service
|
|
||||||
*/
|
|
||||||
public static TestDeprecatedServiceStub newStub(io.grpc.Channel channel) {
|
|
||||||
return new TestDeprecatedServiceStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
|
||||||
*/
|
|
||||||
public static TestDeprecatedServiceBlockingStub newBlockingStub(
|
|
||||||
io.grpc.Channel channel) {
|
|
||||||
return new TestDeprecatedServiceBlockingStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
|
||||||
*/
|
|
||||||
public static TestDeprecatedServiceFutureStub newFutureStub(
|
|
||||||
io.grpc.Channel channel) {
|
|
||||||
return new TestDeprecatedServiceFutureStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public static abstract class TestDeprecatedServiceImplBase implements io.grpc.BindableService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* An RPC method that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public void deprecatedMethod(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getDeprecatedMethodMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
|
||||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
|
||||||
.addMethod(
|
|
||||||
getDeprecatedMethodMethod(),
|
|
||||||
asyncUnaryCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleResponse>(
|
|
||||||
this, METHODID_DEPRECATED_METHOD)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public static final class TestDeprecatedServiceStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceStub> {
|
|
||||||
private TestDeprecatedServiceStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestDeprecatedServiceStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected TestDeprecatedServiceStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new TestDeprecatedServiceStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* An RPC method that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public void deprecatedMethod(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
|
|
||||||
asyncUnaryCall(
|
|
||||||
getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public static final class TestDeprecatedServiceBlockingStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceBlockingStub> {
|
|
||||||
private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestDeprecatedServiceBlockingStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected TestDeprecatedServiceBlockingStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new TestDeprecatedServiceBlockingStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* An RPC method that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public io.grpc.testing.compiler.nano.Test.SimpleResponse deprecatedMethod(io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
|
|
||||||
return blockingUnaryCall(
|
|
||||||
getChannel(), getDeprecatedMethodMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public static final class TestDeprecatedServiceFutureStub extends io.grpc.stub.AbstractStub<TestDeprecatedServiceFutureStub> {
|
|
||||||
private TestDeprecatedServiceFutureStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestDeprecatedServiceFutureStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected TestDeprecatedServiceFutureStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new TestDeprecatedServiceFutureStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* An RPC method that has been deprecated and should generate with Java's @Deprecated annotation
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.nano.Test.SimpleResponse> deprecatedMethod(
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
|
|
||||||
return futureUnaryCall(
|
|
||||||
getChannel().newCall(getDeprecatedMethodMethod(), getCallOptions()), request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int METHODID_DEPRECATED_METHOD = 0;
|
|
||||||
|
|
||||||
private static final class MethodHandlers<Req, Resp> implements
|
|
||||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
|
||||||
private final TestDeprecatedServiceImplBase serviceImpl;
|
|
||||||
private final int methodId;
|
|
||||||
|
|
||||||
MethodHandlers(TestDeprecatedServiceImplBase serviceImpl, int methodId) {
|
|
||||||
this.serviceImpl = serviceImpl;
|
|
||||||
this.methodId = methodId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
|
||||||
switch (methodId) {
|
|
||||||
case METHODID_DEPRECATED_METHOD:
|
|
||||||
serviceImpl.deprecatedMethod((io.grpc.testing.compiler.nano.Test.SimpleRequest) request,
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse>) responseObserver);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
|
||||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
|
||||||
switch (methodId) {
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
|
||||||
|
|
||||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
|
||||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
|
||||||
if (result == null) {
|
|
||||||
synchronized (TestDeprecatedServiceGrpc.class) {
|
|
||||||
result = serviceDescriptor;
|
|
||||||
if (result == null) {
|
|
||||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
|
||||||
.addMethod(getDeprecatedMethodMethod())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,664 +0,0 @@
|
||||||
package io.grpc.testing.compiler.nano;
|
|
||||||
|
|
||||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
|
|
||||||
import static io.grpc.stub.ClientCalls.futureUnaryCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
|
||||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that supports all call types.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@javax.annotation.Generated(
|
|
||||||
value = "by gRPC proto compiler (version 1.22.0-SNAPSHOT)",
|
|
||||||
comments = "Source: grpc/testing/compiler/test.proto")
|
|
||||||
public final class TestServiceGrpc {
|
|
||||||
|
|
||||||
private TestServiceGrpc() {}
|
|
||||||
|
|
||||||
public static final String SERVICE_NAME = "grpc.testing.compiler.TestService";
|
|
||||||
|
|
||||||
// Static method descriptors that strictly reflect the proto.
|
|
||||||
private static final int ARG_IN_METHOD_UNARY_CALL = 0;
|
|
||||||
private static final int ARG_OUT_METHOD_UNARY_CALL = 1;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleResponse> getUnaryCallMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleResponse> getUnaryCallMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse> getUnaryCallMethod;
|
|
||||||
if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
if ((getUnaryCallMethod = TestServiceGrpc.getUnaryCallMethod) == null) {
|
|
||||||
TestServiceGrpc.getUnaryCallMethod = getUnaryCallMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.SimpleRequest, io.grpc.testing.compiler.nano.Test.SimpleResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestService", "UnaryCall"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleRequest>(ARG_IN_METHOD_UNARY_CALL)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.SimpleResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.SimpleResponse>(ARG_OUT_METHOD_UNARY_CALL)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getUnaryCallMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ARG_IN_METHOD_STREAMING_OUTPUT_CALL = 2;
|
|
||||||
private static final int ARG_OUT_METHOD_STREAMING_OUTPUT_CALL = 3;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getStreamingOutputCallMethod;
|
|
||||||
if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
if ((getStreamingOutputCallMethod = TestServiceGrpc.getStreamingOutputCallMethod) == null) {
|
|
||||||
TestServiceGrpc.getStreamingOutputCallMethod = getStreamingOutputCallMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestService", "StreamingOutputCall"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_STREAMING_OUTPUT_CALL)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_STREAMING_OUTPUT_CALL)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getStreamingOutputCallMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ARG_IN_METHOD_STREAMING_INPUT_CALL = 4;
|
|
||||||
private static final int ARG_OUT_METHOD_STREAMING_INPUT_CALL = 5;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getStreamingInputCallMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getStreamingInputCallMethod;
|
|
||||||
if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
if ((getStreamingInputCallMethod = TestServiceGrpc.getStreamingInputCallMethod) == null) {
|
|
||||||
TestServiceGrpc.getStreamingInputCallMethod = getStreamingInputCallMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestService", "StreamingInputCall"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>(ARG_IN_METHOD_STREAMING_INPUT_CALL)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(ARG_OUT_METHOD_STREAMING_INPUT_CALL)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getStreamingInputCallMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ARG_IN_METHOD_FULL_BIDI_CALL = 6;
|
|
||||||
private static final int ARG_OUT_METHOD_FULL_BIDI_CALL = 7;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getFullBidiCallMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getFullBidiCallMethod;
|
|
||||||
if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
if ((getFullBidiCallMethod = TestServiceGrpc.getFullBidiCallMethod) == null) {
|
|
||||||
TestServiceGrpc.getFullBidiCallMethod = getFullBidiCallMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestService", "FullBidiCall"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_FULL_BIDI_CALL)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_FULL_BIDI_CALL)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getFullBidiCallMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ARG_IN_METHOD_HALF_BIDI_CALL = 8;
|
|
||||||
private static final int ARG_OUT_METHOD_HALF_BIDI_CALL = 9;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getHalfBidiCallMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> getHalfBidiCallMethod;
|
|
||||||
if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
if ((getHalfBidiCallMethod = TestServiceGrpc.getHalfBidiCallMethod) == null) {
|
|
||||||
TestServiceGrpc.getHalfBidiCallMethod = getHalfBidiCallMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestService", "HalfBidiCall"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest>(ARG_IN_METHOD_HALF_BIDI_CALL)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(ARG_OUT_METHOD_HALF_BIDI_CALL)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getHalfBidiCallMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ARG_IN_METHOD_IMPORT = 10;
|
|
||||||
private static final int ARG_OUT_METHOD_IMPORT = 11;
|
|
||||||
private static volatile io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getImportMethod;
|
|
||||||
|
|
||||||
public static io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getImportMethod() {
|
|
||||||
io.grpc.MethodDescriptor<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> getImportMethod;
|
|
||||||
if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
if ((getImportMethod = TestServiceGrpc.getImportMethod) == null) {
|
|
||||||
TestServiceGrpc.getImportMethod = getImportMethod =
|
|
||||||
io.grpc.MethodDescriptor.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest, io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>newBuilder()
|
|
||||||
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
|
|
||||||
.setFullMethodName(generateFullMethodName(
|
|
||||||
"grpc.testing.compiler.TestService", "Import"))
|
|
||||||
.setSampledToLocalTracing(true)
|
|
||||||
.setRequestMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest>(ARG_IN_METHOD_IMPORT)))
|
|
||||||
.setResponseMarshaller(io.grpc.protobuf.nano.NanoUtils.<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>marshaller(
|
|
||||||
new NanoFactory<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(ARG_OUT_METHOD_IMPORT)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getImportMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class NanoFactory<T extends com.google.protobuf.nano.MessageNano>
|
|
||||||
implements io.grpc.protobuf.nano.MessageNanoFactory<T> {
|
|
||||||
private final int id;
|
|
||||||
|
|
||||||
NanoFactory(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
public T newInstance() {
|
|
||||||
Object o;
|
|
||||||
switch (id) {
|
|
||||||
case ARG_IN_METHOD_UNARY_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.SimpleRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_UNARY_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.SimpleResponse();
|
|
||||||
break;
|
|
||||||
case ARG_IN_METHOD_STREAMING_OUTPUT_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_STREAMING_OUTPUT_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse();
|
|
||||||
break;
|
|
||||||
case ARG_IN_METHOD_STREAMING_INPUT_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_STREAMING_INPUT_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse();
|
|
||||||
break;
|
|
||||||
case ARG_IN_METHOD_FULL_BIDI_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_FULL_BIDI_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse();
|
|
||||||
break;
|
|
||||||
case ARG_IN_METHOD_HALF_BIDI_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_HALF_BIDI_CALL:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse();
|
|
||||||
break;
|
|
||||||
case ARG_IN_METHOD_IMPORT:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest();
|
|
||||||
break;
|
|
||||||
case ARG_OUT_METHOD_IMPORT:
|
|
||||||
o = new io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
T t = (T) o;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new async stub that supports all call types for the service
|
|
||||||
*/
|
|
||||||
public static TestServiceStub newStub(io.grpc.Channel channel) {
|
|
||||||
return new TestServiceStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
|
||||||
*/
|
|
||||||
public static TestServiceBlockingStub newBlockingStub(
|
|
||||||
io.grpc.Channel channel) {
|
|
||||||
return new TestServiceBlockingStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
|
||||||
*/
|
|
||||||
public static TestServiceFutureStub newFutureStub(
|
|
||||||
io.grpc.Channel channel) {
|
|
||||||
return new TestServiceFutureStub(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that supports all call types.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static abstract class TestServiceImplBase implements io.grpc.BindableService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by one response.
|
|
||||||
* The server returns the client payload as-is.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public void unaryCall(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getUnaryCallMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by a sequence of responses (streamed download).
|
|
||||||
* The server returns the payload with client desired type and sizes.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public void streamingOutputCall(io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest request,
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
|
|
||||||
asyncUnimplementedUnaryCall(getStreamingOutputCallMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* A sequence of requests followed by one response (streamed upload).
|
|
||||||
* The server returns the aggregated size of client payload as the result.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> streamingInputCall(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
|
|
||||||
return asyncUnimplementedStreamingCall(getStreamingInputCallMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* A sequence of requests with each request served by the server immediately.
|
|
||||||
* As one request could lead to multiple responses, this interface
|
|
||||||
* demonstrates the idea of full bidirectionality.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> fullBidiCall(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
|
|
||||||
return asyncUnimplementedStreamingCall(getFullBidiCallMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* A sequence of requests followed by a sequence of responses.
|
|
||||||
* The server buffers all the client requests and then serves them in order. A
|
|
||||||
* stream of responses are returned to the client when the server starts with
|
|
||||||
* first request.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> halfBidiCall(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
|
|
||||||
return asyncUnimplementedStreamingCall(getHalfBidiCallMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* An RPC method whose Java name collides with a keyword, and whose generated
|
|
||||||
* method should have a '_' appended.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> import_(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
|
|
||||||
return asyncUnimplementedStreamingCall(getImportMethod(), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
|
||||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
|
||||||
.addMethod(
|
|
||||||
getUnaryCallMethod(),
|
|
||||||
asyncUnaryCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleResponse>(
|
|
||||||
this, METHODID_UNARY_CALL)))
|
|
||||||
.addMethod(
|
|
||||||
getStreamingOutputCallMethod(),
|
|
||||||
asyncServerStreamingCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(
|
|
||||||
this, METHODID_STREAMING_OUTPUT_CALL)))
|
|
||||||
.addMethod(
|
|
||||||
getStreamingInputCallMethod(),
|
|
||||||
asyncClientStreamingCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(
|
|
||||||
this, METHODID_STREAMING_INPUT_CALL)))
|
|
||||||
.addMethod(
|
|
||||||
getFullBidiCallMethod(),
|
|
||||||
asyncBidiStreamingCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(
|
|
||||||
this, METHODID_FULL_BIDI_CALL)))
|
|
||||||
.addMethod(
|
|
||||||
getHalfBidiCallMethod(),
|
|
||||||
asyncBidiStreamingCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>(
|
|
||||||
this, METHODID_HALF_BIDI_CALL)))
|
|
||||||
.addMethod(
|
|
||||||
getImportMethod(),
|
|
||||||
asyncBidiStreamingCall(
|
|
||||||
new MethodHandlers<
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest,
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>(
|
|
||||||
this, METHODID_IMPORT)))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that supports all call types.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static final class TestServiceStub extends io.grpc.stub.AbstractStub<TestServiceStub> {
|
|
||||||
private TestServiceStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestServiceStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected TestServiceStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new TestServiceStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by one response.
|
|
||||||
* The server returns the client payload as-is.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public void unaryCall(io.grpc.testing.compiler.nano.Test.SimpleRequest request,
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse> responseObserver) {
|
|
||||||
asyncUnaryCall(
|
|
||||||
getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by a sequence of responses (streamed download).
|
|
||||||
* The server returns the payload with client desired type and sizes.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public void streamingOutputCall(io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest request,
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
|
|
||||||
asyncServerStreamingCall(
|
|
||||||
getChannel().newCall(getStreamingOutputCallMethod(), getCallOptions()), request, responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* A sequence of requests followed by one response (streamed upload).
|
|
||||||
* The server returns the aggregated size of client payload as the result.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> streamingInputCall(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
|
|
||||||
return asyncClientStreamingCall(
|
|
||||||
getChannel().newCall(getStreamingInputCallMethod(), getCallOptions()), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* A sequence of requests with each request served by the server immediately.
|
|
||||||
* As one request could lead to multiple responses, this interface
|
|
||||||
* demonstrates the idea of full bidirectionality.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> fullBidiCall(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
|
|
||||||
return asyncBidiStreamingCall(
|
|
||||||
getChannel().newCall(getFullBidiCallMethod(), getCallOptions()), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* A sequence of requests followed by a sequence of responses.
|
|
||||||
* The server buffers all the client requests and then serves them in order. A
|
|
||||||
* stream of responses are returned to the client when the server starts with
|
|
||||||
* first request.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest> halfBidiCall(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> responseObserver) {
|
|
||||||
return asyncBidiStreamingCall(
|
|
||||||
getChannel().newCall(getHalfBidiCallMethod(), getCallOptions()), responseObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* An RPC method whose Java name collides with a keyword, and whose generated
|
|
||||||
* method should have a '_' appended.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallRequest> import_(
|
|
||||||
io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse> responseObserver) {
|
|
||||||
return asyncBidiStreamingCall(
|
|
||||||
getChannel().newCall(getImportMethod(), getCallOptions()), responseObserver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that supports all call types.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static final class TestServiceBlockingStub extends io.grpc.stub.AbstractStub<TestServiceBlockingStub> {
|
|
||||||
private TestServiceBlockingStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestServiceBlockingStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected TestServiceBlockingStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new TestServiceBlockingStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by one response.
|
|
||||||
* The server returns the client payload as-is.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public io.grpc.testing.compiler.nano.Test.SimpleResponse unaryCall(io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
|
|
||||||
return blockingUnaryCall(
|
|
||||||
getChannel(), getUnaryCallMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by a sequence of responses (streamed download).
|
|
||||||
* The server returns the payload with client desired type and sizes.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public java.util.Iterator<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse> streamingOutputCall(
|
|
||||||
io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest request) {
|
|
||||||
return blockingServerStreamingCall(
|
|
||||||
getChannel(), getStreamingOutputCallMethod(), getCallOptions(), request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Test service that supports all call types.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static final class TestServiceFutureStub extends io.grpc.stub.AbstractStub<TestServiceFutureStub> {
|
|
||||||
private TestServiceFutureStub(io.grpc.Channel channel) {
|
|
||||||
super(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestServiceFutureStub(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
super(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
protected TestServiceFutureStub build(io.grpc.Channel channel,
|
|
||||||
io.grpc.CallOptions callOptions) {
|
|
||||||
return new TestServiceFutureStub(channel, callOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* One request followed by one response.
|
|
||||||
* The server returns the client payload as-is.
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public com.google.common.util.concurrent.ListenableFuture<io.grpc.testing.compiler.nano.Test.SimpleResponse> unaryCall(
|
|
||||||
io.grpc.testing.compiler.nano.Test.SimpleRequest request) {
|
|
||||||
return futureUnaryCall(
|
|
||||||
getChannel().newCall(getUnaryCallMethod(), getCallOptions()), request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int METHODID_UNARY_CALL = 0;
|
|
||||||
private static final int METHODID_STREAMING_OUTPUT_CALL = 1;
|
|
||||||
private static final int METHODID_STREAMING_INPUT_CALL = 2;
|
|
||||||
private static final int METHODID_FULL_BIDI_CALL = 3;
|
|
||||||
private static final int METHODID_HALF_BIDI_CALL = 4;
|
|
||||||
private static final int METHODID_IMPORT = 5;
|
|
||||||
|
|
||||||
private static final class MethodHandlers<Req, Resp> implements
|
|
||||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
|
||||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
|
||||||
private final TestServiceImplBase serviceImpl;
|
|
||||||
private final int methodId;
|
|
||||||
|
|
||||||
MethodHandlers(TestServiceImplBase serviceImpl, int methodId) {
|
|
||||||
this.serviceImpl = serviceImpl;
|
|
||||||
this.methodId = methodId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
|
||||||
switch (methodId) {
|
|
||||||
case METHODID_UNARY_CALL:
|
|
||||||
serviceImpl.unaryCall((io.grpc.testing.compiler.nano.Test.SimpleRequest) request,
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.SimpleResponse>) responseObserver);
|
|
||||||
break;
|
|
||||||
case METHODID_STREAMING_OUTPUT_CALL:
|
|
||||||
serviceImpl.streamingOutputCall((io.grpc.testing.compiler.nano.Test.StreamingOutputCallRequest) request,
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>) responseObserver);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Override
|
|
||||||
@java.lang.SuppressWarnings("unchecked")
|
|
||||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
|
||||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
|
||||||
switch (methodId) {
|
|
||||||
case METHODID_STREAMING_INPUT_CALL:
|
|
||||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.streamingInputCall(
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>) responseObserver);
|
|
||||||
case METHODID_FULL_BIDI_CALL:
|
|
||||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.fullBidiCall(
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>) responseObserver);
|
|
||||||
case METHODID_HALF_BIDI_CALL:
|
|
||||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.halfBidiCall(
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingOutputCallResponse>) responseObserver);
|
|
||||||
case METHODID_IMPORT:
|
|
||||||
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.import_(
|
|
||||||
(io.grpc.stub.StreamObserver<io.grpc.testing.compiler.nano.Test.StreamingInputCallResponse>) responseObserver);
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
|
||||||
|
|
||||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
|
||||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
|
||||||
if (result == null) {
|
|
||||||
synchronized (TestServiceGrpc.class) {
|
|
||||||
result = serviceDescriptor;
|
|
||||||
if (result == null) {
|
|
||||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
|
||||||
.addMethod(getUnaryCallMethod())
|
|
||||||
.addMethod(getStreamingOutputCallMethod())
|
|
||||||
.addMethod(getStreamingInputCallMethod())
|
|
||||||
.addMethod(getFullBidiCallMethod())
|
|
||||||
.addMethod(getHalfBidiCallMethod())
|
|
||||||
.addMethod(getImportMethod())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
java_library(
|
|
||||||
name = "protobuf_nano",
|
|
||||||
srcs = glob([
|
|
||||||
"src/main/java/**/*.java",
|
|
||||||
]),
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
deps = [
|
|
||||||
"//api",
|
|
||||||
"@com_google_code_findbugs_jsr305//jar",
|
|
||||||
"@com_google_guava_guava//jar",
|
|
||||||
"@com_google_j2objc_j2objc_annotations//jar",
|
|
||||||
"@com_google_protobuf_nano_protobuf_javanano//jar",
|
|
||||||
],
|
|
||||||
)
|
|
|
@ -1,43 +0,0 @@
|
||||||
// Add dependency on the protobuf plugin
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
maven { // The google mirror is less flaky than mavenCentral()
|
|
||||||
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
|
|
||||||
}
|
|
||||||
dependencies { classpath libraries.protobuf_plugin }
|
|
||||||
}
|
|
||||||
|
|
||||||
description = 'gRPC: Protobuf Nano'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile project(':grpc-api'),
|
|
||||||
libraries.protobuf_nano
|
|
||||||
compile (libraries.guava) {
|
|
||||||
// prefer 2.3.2 from libraries instead of 2.1.3
|
|
||||||
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
||||||
// prefer 3.0.2 from libraries instead of 3.0.1
|
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
// prefer 1.17 from libraries instead of 1.14
|
|
||||||
exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations'
|
|
||||||
}
|
|
||||||
signature "org.codehaus.mojo.signature:java17:1.0@signature"
|
|
||||||
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
|
|
||||||
}
|
|
||||||
|
|
||||||
configureProtoCompilation()
|
|
||||||
|
|
||||||
if (project.hasProperty('protobuf')) {
|
|
||||||
protobuf {
|
|
||||||
protoc {
|
|
||||||
artifact = libraries.protoc_nano
|
|
||||||
}
|
|
||||||
generateProtoTasks {
|
|
||||||
all().each { task ->
|
|
||||||
task.builtins {
|
|
||||||
remove java
|
|
||||||
javanano { option 'ignore_services=true' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2014 The gRPC Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.grpc.protobuf.nano;
|
|
||||||
|
|
||||||
import com.google.protobuf.nano.MessageNano;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Produce new message instances. Used by a marshaller to deserialize incoming messages.
|
|
||||||
*
|
|
||||||
* <p>Should be implemented by generated code.
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public interface MessageNanoFactory<T extends MessageNano> {
|
|
||||||
T newInstance();
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2014 The gRPC Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.grpc.protobuf.nano;
|
|
||||||
|
|
||||||
import com.google.protobuf.nano.CodedOutputByteBufferNano;
|
|
||||||
import com.google.protobuf.nano.MessageNano;
|
|
||||||
import io.grpc.KnownLength;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An {@link InputStream} backed by a nano proto.
|
|
||||||
*/
|
|
||||||
final class NanoProtoInputStream extends InputStream implements KnownLength {
|
|
||||||
|
|
||||||
// NanoProtoInputStream is first initialized with a *message*. *partial* is initially null.
|
|
||||||
// Once there has been a read operation on this stream, *message* is serialized to *partial* and
|
|
||||||
// set to null.
|
|
||||||
@Nullable private MessageNano message;
|
|
||||||
@Nullable private ByteArrayInputStream partial;
|
|
||||||
|
|
||||||
NanoProtoInputStream(MessageNano message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toPartial() {
|
|
||||||
if (message != null) {
|
|
||||||
partial = new ByteArrayInputStream(MessageNano.toByteArray(message));
|
|
||||||
message = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read() throws IOException {
|
|
||||||
toPartial();
|
|
||||||
if (partial != null) {
|
|
||||||
return partial.read();
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] b, int off, int len) throws IOException {
|
|
||||||
if (message != null) {
|
|
||||||
int size = message.getSerializedSize();
|
|
||||||
if (size == 0) {
|
|
||||||
message = null;
|
|
||||||
partial = null;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (len >= size) {
|
|
||||||
// This is the only case that is zero-copy.
|
|
||||||
CodedOutputByteBufferNano output = CodedOutputByteBufferNano.newInstance(b, off, size);
|
|
||||||
message.writeTo(output);
|
|
||||||
output.checkNoSpaceLeft();
|
|
||||||
|
|
||||||
message = null;
|
|
||||||
partial = null;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
toPartial();
|
|
||||||
}
|
|
||||||
if (partial != null) {
|
|
||||||
return partial.read(b, off, len);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int available() {
|
|
||||||
if (message != null) {
|
|
||||||
return message.getSerializedSize();
|
|
||||||
} else if (partial != null) {
|
|
||||||
return partial.available();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2014 The gRPC Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.grpc.protobuf.nano;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.google.protobuf.nano.CodedInputByteBufferNano;
|
|
||||||
import com.google.protobuf.nano.MessageNano;
|
|
||||||
import io.grpc.MethodDescriptor.Marshaller;
|
|
||||||
import io.grpc.Status;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility methods for using nano proto with grpc.
|
|
||||||
*/
|
|
||||||
public final class NanoUtils {
|
|
||||||
|
|
||||||
private NanoUtils() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapt {@code parser} to a {@link Marshaller}.
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
public static <T extends MessageNano> Marshaller<T> marshaller(MessageNanoFactory<T> factory) {
|
|
||||||
return new MessageMarshaller<>(factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class MessageMarshaller<T extends MessageNano> implements Marshaller<T> {
|
|
||||||
private static final int BUF_SIZE = 8192;
|
|
||||||
|
|
||||||
private final MessageNanoFactory<T> factory;
|
|
||||||
|
|
||||||
MessageMarshaller(MessageNanoFactory<T> factory) {
|
|
||||||
this.factory = factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream stream(T value) {
|
|
||||||
return new NanoProtoInputStream(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T parse(InputStream stream) {
|
|
||||||
try {
|
|
||||||
// TODO(simonma): Investigate whether we can do 0-copy here.
|
|
||||||
CodedInputByteBufferNano input =
|
|
||||||
CodedInputByteBufferNano.newInstance(toByteArray(stream));
|
|
||||||
input.setSizeLimit(Integer.MAX_VALUE);
|
|
||||||
T message = factory.newInstance();
|
|
||||||
message.mergeFrom(input);
|
|
||||||
return message;
|
|
||||||
} catch (IOException ipbe) {
|
|
||||||
throw Status.INTERNAL.withDescription("Failed parsing nano proto message").withCause(ipbe)
|
|
||||||
.asRuntimeException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copied from guava com.google.common.io.ByteStreams because its API is unstable (beta)
|
|
||||||
private static byte[] toByteArray(InputStream in) throws IOException {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
copy(in, out);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copied from guava com.google.common.io.ByteStreams because its API is unstable (beta)
|
|
||||||
private static long copy(InputStream from, OutputStream to) throws IOException {
|
|
||||||
checkNotNull(from);
|
|
||||||
checkNotNull(to);
|
|
||||||
byte[] buf = new byte[BUF_SIZE];
|
|
||||||
long total = 0;
|
|
||||||
while (true) {
|
|
||||||
int r = from.read(buf);
|
|
||||||
if (r == -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
to.write(buf, 0, r);
|
|
||||||
total += r;
|
|
||||||
}
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2017 The gRPC Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API for gRPC over Protocol Buffers with proto message classes generated by the JavaNano compiler.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.grpc.protobuf.nano;
|
|
|
@ -1,116 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2015 The gRPC Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.grpc.protobuf.nano;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotSame;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import com.google.protobuf.nano.InvalidProtocolBufferNanoException;
|
|
||||||
import com.google.protobuf.nano.MessageNano;
|
|
||||||
import io.grpc.MethodDescriptor.Marshaller;
|
|
||||||
import io.grpc.Status;
|
|
||||||
import io.grpc.StatusRuntimeException;
|
|
||||||
import io.grpc.protobuf.nano.Messages.Message;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.junit.runners.JUnit4;
|
|
||||||
|
|
||||||
/** Unit tests for {@link NanoUtils}. */
|
|
||||||
@RunWith(JUnit4.class)
|
|
||||||
public class NanoUtilsTest {
|
|
||||||
private Marshaller<Message> marshaller = NanoUtils.marshaller(new MessageNanoFactory<Message>() {
|
|
||||||
@Override
|
|
||||||
public Message newInstance() {
|
|
||||||
return new Message();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRoundTrip() {
|
|
||||||
Message m = new Message();
|
|
||||||
m.i = 2;
|
|
||||||
m.b = true;
|
|
||||||
m.s = "string";
|
|
||||||
Message m2 = marshaller.parse(marshaller.stream(m));
|
|
||||||
assertNotSame(m, m2);
|
|
||||||
assertEquals(2, m2.i);
|
|
||||||
assertEquals(true, m2.b);
|
|
||||||
assertEquals("string", m2.s);
|
|
||||||
assertTrue(MessageNano.messageNanoEquals(m, m2));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void parseInvalid() throws Exception {
|
|
||||||
InputStream is = new ByteArrayInputStream(new byte[] {-127});
|
|
||||||
try {
|
|
||||||
marshaller.parse(is);
|
|
||||||
fail("Expected exception");
|
|
||||||
} catch (StatusRuntimeException ex) {
|
|
||||||
assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
|
|
||||||
assertTrue(ex.getCause() instanceof InvalidProtocolBufferNanoException);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLarge() {
|
|
||||||
Message m = new Message();
|
|
||||||
// The default limit is 64MB. Using a larger proto to verify that the limit is not enforced.
|
|
||||||
m.bs = new byte[70 * 1024 * 1024];
|
|
||||||
Message m2 = marshaller.parse(marshaller.stream(m));
|
|
||||||
assertNotSame(m, m2);
|
|
||||||
// TODO(carl-mastrangelo): assertArrayEquals is REALLY slow, and been fixed in junit4.12.
|
|
||||||
// Eventually switch back to it once we are using 4.12 everywhere.
|
|
||||||
// assertArrayEquals(m.bs, m2.bs);
|
|
||||||
assertEquals(m.bs.length, m2.bs.length);
|
|
||||||
for (int i = 0; i < m.bs.length; i++) {
|
|
||||||
assertEquals(m.bs[i], m2.bs[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAvailable() throws Exception {
|
|
||||||
Message m = new Message();
|
|
||||||
m.s = "string";
|
|
||||||
InputStream is = marshaller.stream(m);
|
|
||||||
assertEquals(m.getSerializedSize(), is.available());
|
|
||||||
is.read();
|
|
||||||
assertEquals(m.getSerializedSize() - 1, is.available());
|
|
||||||
while (is.read() != -1) {}
|
|
||||||
assertEquals(-1, is.read());
|
|
||||||
assertEquals(0, is.available());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEmpty() throws IOException {
|
|
||||||
InputStream is = marshaller.stream(new Message());
|
|
||||||
assertEquals(0, is.available());
|
|
||||||
byte[] b = new byte[10];
|
|
||||||
assertEquals(-1, is.read(b));
|
|
||||||
assertArrayEquals(new byte[10], b);
|
|
||||||
// Do the same thing again, because the internal state may be different
|
|
||||||
assertEquals(-1, is.read(b));
|
|
||||||
assertArrayEquals(new byte[10], b);
|
|
||||||
assertEquals(-1, is.read());
|
|
||||||
assertEquals(0, is.available());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
|
|
||||||
// Copyright 2015 The gRPC Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package grpc.testing.nano;
|
|
||||||
|
|
||||||
option java_package = "io.grpc.protobuf";
|
|
||||||
|
|
||||||
message Message {
|
|
||||||
int32 i = 1;
|
|
||||||
bool b = 2;
|
|
||||||
string s = 3;
|
|
||||||
bytes bs = 4;
|
|
||||||
}
|
|
|
@ -18,7 +18,6 @@ def grpc_java_repositories(
|
||||||
omit_com_google_protobuf = False,
|
omit_com_google_protobuf = False,
|
||||||
omit_com_google_protobuf_java = False,
|
omit_com_google_protobuf_java = False,
|
||||||
omit_com_google_protobuf_javalite = False,
|
omit_com_google_protobuf_javalite = False,
|
||||||
omit_com_google_protobuf_nano_protobuf_javanano = False,
|
|
||||||
omit_com_google_truth_truth = False,
|
omit_com_google_truth_truth = False,
|
||||||
omit_com_squareup_okhttp = False,
|
omit_com_squareup_okhttp = False,
|
||||||
omit_com_squareup_okio = False,
|
omit_com_squareup_okio = False,
|
||||||
|
@ -70,8 +69,6 @@ def grpc_java_repositories(
|
||||||
fail("omit_com_google_protobuf_java is no longer supported and must be not be passed to grpc_java_repositories()")
|
fail("omit_com_google_protobuf_java is no longer supported and must be not be passed to grpc_java_repositories()")
|
||||||
if not omit_com_google_protobuf_javalite:
|
if not omit_com_google_protobuf_javalite:
|
||||||
com_google_protobuf_javalite()
|
com_google_protobuf_javalite()
|
||||||
if not omit_com_google_protobuf_nano_protobuf_javanano:
|
|
||||||
com_google_protobuf_nano_protobuf_javanano()
|
|
||||||
if not omit_com_google_truth_truth:
|
if not omit_com_google_truth_truth:
|
||||||
com_google_truth_truth()
|
com_google_truth_truth()
|
||||||
if not omit_com_squareup_okhttp:
|
if not omit_com_squareup_okhttp:
|
||||||
|
@ -253,15 +250,6 @@ def com_google_protobuf_javalite():
|
||||||
urls = ["https://github.com/google/protobuf/archive/384989534b2246d413dbcd750744faab2607b516.zip"],
|
urls = ["https://github.com/google/protobuf/archive/384989534b2246d413dbcd750744faab2607b516.zip"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def com_google_protobuf_nano_protobuf_javanano():
|
|
||||||
jvm_maven_import_external(
|
|
||||||
name = "com_google_protobuf_nano_protobuf_javanano",
|
|
||||||
artifact = "com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-5",
|
|
||||||
server_urls = ["http://central.maven.org/maven2"],
|
|
||||||
artifact_sha256 = "6d30f1e667a8952e1c90a0a125f0ce0edf84d6b1d51c91d8555c4fb549e3d7a1",
|
|
||||||
licenses = ["notice"], # BSD 2-clause
|
|
||||||
)
|
|
||||||
|
|
||||||
def com_google_truth_truth():
|
def com_google_truth_truth():
|
||||||
jvm_maven_import_external(
|
jvm_maven_import_external(
|
||||||
name = "com_google_truth_truth",
|
name = "com_google_truth_truth",
|
||||||
|
|
|
@ -7,7 +7,6 @@ include ":grpc-auth"
|
||||||
include ":grpc-okhttp"
|
include ":grpc-okhttp"
|
||||||
include ":grpc-protobuf"
|
include ":grpc-protobuf"
|
||||||
include ":grpc-protobuf-lite"
|
include ":grpc-protobuf-lite"
|
||||||
include ":grpc-protobuf-nano"
|
|
||||||
include ":grpc-netty"
|
include ":grpc-netty"
|
||||||
include ":grpc-netty-shaded"
|
include ":grpc-netty-shaded"
|
||||||
include ":grpc-grpclb"
|
include ":grpc-grpclb"
|
||||||
|
@ -30,7 +29,6 @@ project(':grpc-auth').projectDir = "$rootDir/auth" as File
|
||||||
project(':grpc-okhttp').projectDir = "$rootDir/okhttp" as File
|
project(':grpc-okhttp').projectDir = "$rootDir/okhttp" as File
|
||||||
project(':grpc-protobuf').projectDir = "$rootDir/protobuf" as File
|
project(':grpc-protobuf').projectDir = "$rootDir/protobuf" as File
|
||||||
project(':grpc-protobuf-lite').projectDir = "$rootDir/protobuf-lite" as File
|
project(':grpc-protobuf-lite').projectDir = "$rootDir/protobuf-lite" as File
|
||||||
project(':grpc-protobuf-nano').projectDir = "$rootDir/protobuf-nano" as File
|
|
||||||
project(':grpc-netty').projectDir = "$rootDir/netty" as File
|
project(':grpc-netty').projectDir = "$rootDir/netty" as File
|
||||||
project(':grpc-netty-shaded').projectDir = "$rootDir/netty/shaded" as File
|
project(':grpc-netty-shaded').projectDir = "$rootDir/netty/shaded" as File
|
||||||
project(':grpc-grpclb').projectDir = "$rootDir/grpclb" as File
|
project(':grpc-grpclb').projectDir = "$rootDir/grpclb" as File
|
||||||
|
|
Loading…
Reference in New Issue