Update example template
This commit is contained in:
parent
81310a7f0f
commit
54eb016142
@ -1,107 +1,157 @@
|
|||||||
|
// @flow
|
||||||
// GENERATED CODE -- DO NOT EDIT!
|
// GENERATED CODE -- DO NOT EDIT!
|
||||||
|
|
||||||
'use strict';
|
import grpc from 'grpc'
|
||||||
var grpc = require('grpc');
|
import pbFile from './pbFile.js'
|
||||||
var test_pb = require('./test_pb.js');
|
|
||||||
|
|
||||||
|
|
||||||
function serialize_test_TestNoStreamRequest(arg) {
|
export type TestMessage = {|
|
||||||
if (!(arg instanceof test_pb.TestNoStreamRequest)) {
|
a?: string;
|
||||||
throw new Error('Expected argument of type test.TestNoStreamRequest');
|
b?: number;
|
||||||
|
c?: number;
|
||||||
|
d?: number;
|
||||||
|
e?: number;
|
||||||
|
n?: Array<string>;
|
||||||
|
o?: Array<number>;
|
||||||
|
p?: Array<number>;
|
||||||
|
q?: Array<number>;
|
||||||
|
r?: Array<number>;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestNoStreamRequest = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestNoStreamReply = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
err_msg?: string;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestStreamRequestRequest = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestStreamRequestReply = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
err_msg?: string;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestStreamReplyRequest = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestStreamReplyReply = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
err_msg?: string;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestStreamBothRequest = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
|};
|
||||||
|
|
||||||
|
export type TestStreamBothReply = {|
|
||||||
|
message?: TestMessage;
|
||||||
|
err_msg?: string;
|
||||||
|
|};
|
||||||
|
|
||||||
|
|
||||||
|
function serialize_test_TestNoStreamRequest(arg: TestNoStreamRequest) {
|
||||||
|
if (!(arg instanceof pbFile.TestNoStreamRequest)) {
|
||||||
|
throw new Error('Expected argument of type TestNoStreamRequest')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestNoStreamRequest(buffer_arg) {
|
function deserialize_test_TestNoStreamRequest(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestNoStreamRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestNoStreamRequest.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestNoStreamReply(arg) {
|
function serialize_test_TestNoStreamReply(arg: TestNoStreamReply) {
|
||||||
if (!(arg instanceof test_pb.TestNoStreamReply)) {
|
if (!(arg instanceof pbFile.TestNoStreamReply)) {
|
||||||
throw new Error('Expected argument of type test.TestNoStreamReply');
|
throw new Error('Expected argument of type TestNoStreamReply')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestNoStreamReply(buffer_arg) {
|
function deserialize_test_TestNoStreamReply(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestNoStreamReply.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestNoStreamReply.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestStreamRequestRequest(arg) {
|
function serialize_test_TestStreamRequestRequest(arg: TestStreamRequestRequest) {
|
||||||
if (!(arg instanceof test_pb.TestStreamRequestRequest)) {
|
if (!(arg instanceof pbFile.TestStreamRequestRequest)) {
|
||||||
throw new Error('Expected argument of type test.TestStreamRequestRequest');
|
throw new Error('Expected argument of type TestStreamRequestRequest')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestStreamRequestRequest(buffer_arg) {
|
function deserialize_test_TestStreamRequestRequest(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestStreamRequestRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestStreamRequestRequest.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestStreamRequestReply(arg) {
|
function serialize_test_TestStreamRequestReply(arg: TestStreamRequestReply) {
|
||||||
if (!(arg instanceof test_pb.TestStreamRequestReply)) {
|
if (!(arg instanceof pbFile.TestStreamRequestReply)) {
|
||||||
throw new Error('Expected argument of type test.TestStreamRequestReply');
|
throw new Error('Expected argument of type TestStreamRequestReply')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestStreamRequestReply(buffer_arg) {
|
function deserialize_test_TestStreamRequestReply(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestStreamRequestReply.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestStreamRequestReply.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestStreamReplyRequest(arg) {
|
function serialize_test_TestStreamReplyRequest(arg: TestStreamReplyRequest) {
|
||||||
if (!(arg instanceof test_pb.TestStreamReplyRequest)) {
|
if (!(arg instanceof pbFile.TestStreamReplyRequest)) {
|
||||||
throw new Error('Expected argument of type test.TestStreamReplyRequest');
|
throw new Error('Expected argument of type TestStreamReplyRequest')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestStreamReplyRequest(buffer_arg) {
|
function deserialize_test_TestStreamReplyRequest(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestStreamReplyRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestStreamReplyRequest.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestStreamReplyReply(arg) {
|
function serialize_test_TestStreamReplyReply(arg: TestStreamReplyReply) {
|
||||||
if (!(arg instanceof test_pb.TestStreamReplyReply)) {
|
if (!(arg instanceof pbFile.TestStreamReplyReply)) {
|
||||||
throw new Error('Expected argument of type test.TestStreamReplyReply');
|
throw new Error('Expected argument of type TestStreamReplyReply')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestStreamReplyReply(buffer_arg) {
|
function deserialize_test_TestStreamReplyReply(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestStreamReplyReply.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestStreamReplyReply.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestStreamBothRequest(arg) {
|
function serialize_test_TestStreamBothRequest(arg: TestStreamBothRequest) {
|
||||||
if (!(arg instanceof test_pb.TestStreamBothRequest)) {
|
if (!(arg instanceof pbFile.TestStreamBothRequest)) {
|
||||||
throw new Error('Expected argument of type test.TestStreamBothRequest');
|
throw new Error('Expected argument of type TestStreamBothRequest')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestStreamBothRequest(buffer_arg) {
|
function deserialize_test_TestStreamBothRequest(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestStreamBothRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestStreamBothRequest.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_test_TestStreamBothReply(arg) {
|
function serialize_test_TestStreamBothReply(arg: TestStreamBothReply) {
|
||||||
if (!(arg instanceof test_pb.TestStreamBothReply)) {
|
if (!(arg instanceof pbFile.TestStreamBothReply)) {
|
||||||
throw new Error('Expected argument of type test.TestStreamBothReply');
|
throw new Error('Expected argument of type TestStreamBothReply')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_test_TestStreamBothReply(buffer_arg) {
|
function deserialize_test_TestStreamBothReply(buffer_arg: Array<number>) {
|
||||||
return test_pb.TestStreamBothReply.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.TestStreamBothReply.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var TestServiceService = exports.TestServiceService = {
|
export const TestServiceService = {
|
||||||
|
|
||||||
testNoStream: {
|
testNoStream: {
|
||||||
path: '/test.TestService/TestNoStream',
|
path: '/test.TestService/TestNoStream',
|
||||||
requestStream: false,
|
requestStream: false,
|
||||||
responseStream: false,
|
responseStream: false,
|
||||||
requestType: test_pb.TestNoStreamRequest,
|
requestType: pbFile.TestNoStreamRequest,
|
||||||
responseType: test_pb.TestNoStreamReply,
|
responseType: pbFile.TestNoStreamReply,
|
||||||
requestSerialize: serialize_test_TestNoStreamRequest,
|
requestSerialize: serialize_test_TestNoStreamRequest,
|
||||||
requestDeserialize: deserialize_test_TestNoStreamRequest,
|
requestDeserialize: deserialize_test_TestNoStreamRequest,
|
||||||
responseSerialize: serialize_test_TestNoStreamReply,
|
responseSerialize: serialize_test_TestNoStreamReply,
|
||||||
@ -111,8 +161,8 @@ var TestServiceService = exports.TestServiceService = {
|
|||||||
path: '/test.TestService/TestStreamRequest',
|
path: '/test.TestService/TestStreamRequest',
|
||||||
requestStream: true,
|
requestStream: true,
|
||||||
responseStream: false,
|
responseStream: false,
|
||||||
requestType: test_pb.TestStreamRequestRequest,
|
requestType: pbFile.TestStreamRequestRequest,
|
||||||
responseType: test_pb.TestStreamRequestReply,
|
responseType: pbFile.TestStreamRequestReply,
|
||||||
requestSerialize: serialize_test_TestStreamRequestRequest,
|
requestSerialize: serialize_test_TestStreamRequestRequest,
|
||||||
requestDeserialize: deserialize_test_TestStreamRequestRequest,
|
requestDeserialize: deserialize_test_TestStreamRequestRequest,
|
||||||
responseSerialize: serialize_test_TestStreamRequestReply,
|
responseSerialize: serialize_test_TestStreamRequestReply,
|
||||||
@ -122,8 +172,8 @@ var TestServiceService = exports.TestServiceService = {
|
|||||||
path: '/test.TestService/TestStreamReply',
|
path: '/test.TestService/TestStreamReply',
|
||||||
requestStream: false,
|
requestStream: false,
|
||||||
responseStream: true,
|
responseStream: true,
|
||||||
requestType: test_pb.TestStreamReplyRequest,
|
requestType: pbFile.TestStreamReplyRequest,
|
||||||
responseType: test_pb.TestStreamReplyReply,
|
responseType: pbFile.TestStreamReplyReply,
|
||||||
requestSerialize: serialize_test_TestStreamReplyRequest,
|
requestSerialize: serialize_test_TestStreamReplyRequest,
|
||||||
requestDeserialize: deserialize_test_TestStreamReplyRequest,
|
requestDeserialize: deserialize_test_TestStreamReplyRequest,
|
||||||
responseSerialize: serialize_test_TestStreamReplyReply,
|
responseSerialize: serialize_test_TestStreamReplyReply,
|
||||||
@ -133,8 +183,8 @@ var TestServiceService = exports.TestServiceService = {
|
|||||||
path: '/test.TestService/TestStreamBoth',
|
path: '/test.TestService/TestStreamBoth',
|
||||||
requestStream: true,
|
requestStream: true,
|
||||||
responseStream: true,
|
responseStream: true,
|
||||||
requestType: test_pb.TestStreamBothRequest,
|
requestType: pbFile.TestStreamBothRequest,
|
||||||
responseType: test_pb.TestStreamBothReply,
|
responseType: pbFile.TestStreamBothReply,
|
||||||
requestSerialize: serialize_test_TestStreamBothRequest,
|
requestSerialize: serialize_test_TestStreamBothRequest,
|
||||||
requestDeserialize: deserialize_test_TestStreamBothRequest,
|
requestDeserialize: deserialize_test_TestStreamBothRequest,
|
||||||
responseSerialize: serialize_test_TestStreamBothReply,
|
responseSerialize: serialize_test_TestStreamBothReply,
|
||||||
@ -143,4 +193,4 @@ var TestServiceService = exports.TestServiceService = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.TestServiceClient = grpc.makeGenericClientConstructor(TestServiceService);
|
export const TestServiceClient = grpc.makeGenericClientConstructor(TestServiceService)
|
||||||
|
@ -1,47 +1,57 @@
|
|||||||
|
// @flow
|
||||||
// GENERATED CODE -- DO NOT EDIT!
|
// GENERATED CODE -- DO NOT EDIT!
|
||||||
{{$Package:=.File.Package}}
|
{{$Package:=.File.Package}}
|
||||||
'use strict';
|
import grpc from 'grpc'
|
||||||
var grpc = require('grpc');
|
import pbFile from './pbFile.js'
|
||||||
var {{$Package}}_pb = require('./{{$Package}}_pb.js');
|
{{range .File.EnumType}}export type {{.Name}} = {{range .Value}}
|
||||||
|
| '{{.Name}}'{{end}}
|
||||||
|
;{{end}}
|
||||||
|
{{range .File.MessageType}}
|
||||||
|
export type {{.Name}} = {|{{range .Field}}
|
||||||
|
{{.Name}}?: {{. | jsType}};{{end}}{{range .EnumType}}
|
||||||
|
{{.Name}}?:{{range .Value}}
|
||||||
|
| '{{.Name}}'{{end}}
|
||||||
|
;{{end}}
|
||||||
|
|};
|
||||||
|
{{end}}
|
||||||
{{range .File.Service}}{{range .Method}}
|
{{range .File.Service}}{{range .Method}}
|
||||||
function serialize_{{$Package}}_{{.InputType | splitArray "." | last}}(arg) {
|
function serialize_{{$Package}}_{{.InputType | shortType}}(arg: {{.InputType | shortType}}) {
|
||||||
if (!(arg instanceof {{$Package}}_pb.{{.InputType | splitArray "." | last}})) {
|
if (!(arg instanceof pbFile.{{.InputType | shortType}})) {
|
||||||
throw new Error('Expected argument of type {{$Package}}.{{.InputType | splitArray "." | last}}');
|
throw new Error('Expected argument of type {{.InputType | shortType}}')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_{{$Package}}_{{.InputType | splitArray "." | last}}(buffer_arg) {
|
function deserialize_{{$Package}}_{{.InputType | shortType}}(buffer_arg: Array<number>) {
|
||||||
return {{$Package}}_pb.{{.InputType | splitArray "." | last}}.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.{{.InputType | shortType}}.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function serialize_{{$Package}}_{{.OutputType | splitArray "." | last}}(arg) {
|
function serialize_{{$Package}}_{{.OutputType | shortType}}(arg: {{.OutputType | shortType}}) {
|
||||||
if (!(arg instanceof {{$Package}}_pb.{{.OutputType | splitArray "." | last}})) {
|
if (!(arg instanceof pbFile.{{.OutputType | shortType}})) {
|
||||||
throw new Error('Expected argument of type {{$Package}}.{{.OutputType | splitArray "." | last}}');
|
throw new Error('Expected argument of type {{.OutputType | shortType}}')
|
||||||
}
|
}
|
||||||
return new Buffer(arg.serializeBinary());
|
return new Buffer(arg.serializeBinary())
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserialize_{{$Package}}_{{.OutputType | splitArray "." | last}}(buffer_arg) {
|
function deserialize_{{$Package}}_{{.OutputType | shortType}}(buffer_arg: Array<number>) {
|
||||||
return {{$Package}}_pb.{{.OutputType | splitArray "." | last}}.deserializeBinary(new Uint8Array(buffer_arg));
|
return pbFile.{{.OutputType | shortType}}.deserializeBinary(new Uint8Array(buffer_arg))
|
||||||
}
|
}
|
||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
{{range .File.Service}}
|
{{range .File.Service}}
|
||||||
var {{.Name}}Service = exports.{{.Name}}Service = {
|
export const {{.Name}}Service = {
|
||||||
{{$serviceName:=.Name}}
|
{{$serviceName:=.Name}}
|
||||||
{{range .Method}}{{.Name | lowerCamelCase}}: {
|
{{range .Method}}{{.Name | lowerCamelCase}}: {
|
||||||
path: '/{{$Package}}.{{$serviceName}}/{{.Name}}',
|
path: '/{{$Package}}.{{$serviceName}}/{{.Name}}',
|
||||||
requestStream: {{.ClientStreaming | default "false"}},
|
requestStream: {{.ClientStreaming | default "false"}},
|
||||||
responseStream: {{.ServerStreaming | default "false"}},
|
responseStream: {{.ServerStreaming | default "false"}},
|
||||||
requestType: {{$Package}}_pb.{{.InputType | splitArray "." | last}},
|
requestType: pbFile.{{.InputType | shortType}},
|
||||||
responseType: {{$Package}}_pb.{{.OutputType | splitArray "." | last}},
|
responseType: pbFile.{{.OutputType | shortType}},
|
||||||
requestSerialize: serialize_{{$Package}}_{{.InputType | splitArray "." | last}},
|
requestSerialize: serialize_{{$Package}}_{{.InputType | shortType}},
|
||||||
requestDeserialize: deserialize_{{$Package}}_{{.InputType | splitArray "." | last}},
|
requestDeserialize: deserialize_{{$Package}}_{{.InputType | shortType}},
|
||||||
responseSerialize: serialize_{{$Package}}_{{.OutputType | splitArray "." | last}},
|
responseSerialize: serialize_{{$Package}}_{{.OutputType | shortType}},
|
||||||
responseDeserialize: deserialize_{{$Package}}_{{.OutputType | splitArray "." | last}},
|
responseDeserialize: deserialize_{{$Package}}_{{.OutputType | shortType}},
|
||||||
},
|
},
|
||||||
{{end}}
|
{{end}}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.{{.Name}}Client = grpc.makeGenericClientConstructor({{.Name}}Service);{{end}}
|
export const {{.Name}}Client = grpc.makeGenericClientConstructor({{.Name}}Service){{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user