protoc-gen-go-micro/examples/js-grpc/output/test/test_grpc_js.js

197 lines
6.0 KiB
JavaScript
Raw Normal View History

2017-01-05 20:06:24 +03:00
// @flow
2016-12-20 13:31:46 +03:00
// GENERATED CODE -- DO NOT EDIT!
2017-01-05 20:06:24 +03:00
import grpc from 'grpc'
import pbFile from './pbFile.js'
2017-01-05 20:26:35 +03:00
type TestMessage = {|
2017-01-05 20:06:24 +03:00
a?: string;
b?: number;
c?: number;
d?: number;
e?: number;
n?: Array<string>;
o?: Array<number>;
p?: Array<number>;
q?: Array<number>;
r?: Array<number>;
|};
2017-01-05 20:26:35 +03:00
type TestNoStreamRequest = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
|};
2017-01-05 20:26:35 +03:00
type TestNoStreamReply = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
err_msg?: string;
|};
2017-01-05 20:26:35 +03:00
type TestStreamRequestRequest = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
|};
2017-01-05 20:26:35 +03:00
type TestStreamRequestReply = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
err_msg?: string;
|};
2017-01-05 20:26:35 +03:00
type TestStreamReplyRequest = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
|};
2017-01-05 20:26:35 +03:00
type TestStreamReplyReply = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
err_msg?: string;
|};
2017-01-05 20:26:35 +03:00
type TestStreamBothRequest = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
|};
2017-01-05 20:26:35 +03:00
type TestStreamBothReply = {|
2017-01-05 20:06:24 +03:00
message?: TestMessage;
err_msg?: string;
|};
function serialize_test_TestNoStreamRequest(arg: TestNoStreamRequest) {
if (!(arg instanceof pbFile.TestNoStreamRequest)) {
throw new Error('Expected argument of type TestNoStreamRequest')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestNoStreamRequest(buffer_arg: Array<number>) {
return pbFile.TestNoStreamRequest.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestNoStreamReply(arg: TestNoStreamReply) {
if (!(arg instanceof pbFile.TestNoStreamReply)) {
throw new Error('Expected argument of type TestNoStreamReply')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestNoStreamReply(buffer_arg: Array<number>) {
return pbFile.TestNoStreamReply.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestStreamRequestRequest(arg: TestStreamRequestRequest) {
if (!(arg instanceof pbFile.TestStreamRequestRequest)) {
throw new Error('Expected argument of type TestStreamRequestRequest')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestStreamRequestRequest(buffer_arg: Array<number>) {
return pbFile.TestStreamRequestRequest.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestStreamRequestReply(arg: TestStreamRequestReply) {
if (!(arg instanceof pbFile.TestStreamRequestReply)) {
throw new Error('Expected argument of type TestStreamRequestReply')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestStreamRequestReply(buffer_arg: Array<number>) {
return pbFile.TestStreamRequestReply.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestStreamReplyRequest(arg: TestStreamReplyRequest) {
if (!(arg instanceof pbFile.TestStreamReplyRequest)) {
throw new Error('Expected argument of type TestStreamReplyRequest')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestStreamReplyRequest(buffer_arg: Array<number>) {
return pbFile.TestStreamReplyRequest.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestStreamReplyReply(arg: TestStreamReplyReply) {
if (!(arg instanceof pbFile.TestStreamReplyReply)) {
throw new Error('Expected argument of type TestStreamReplyReply')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestStreamReplyReply(buffer_arg: Array<number>) {
return pbFile.TestStreamReplyReply.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestStreamBothRequest(arg: TestStreamBothRequest) {
if (!(arg instanceof pbFile.TestStreamBothRequest)) {
throw new Error('Expected argument of type TestStreamBothRequest')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestStreamBothRequest(buffer_arg: Array<number>) {
return pbFile.TestStreamBothRequest.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function serialize_test_TestStreamBothReply(arg: TestStreamBothReply) {
if (!(arg instanceof pbFile.TestStreamBothReply)) {
throw new Error('Expected argument of type TestStreamBothReply')
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
return new Buffer(arg.serializeBinary())
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
function deserialize_test_TestStreamBothReply(buffer_arg: Array<number>) {
return pbFile.TestStreamBothReply.deserializeBinary(new Uint8Array(buffer_arg))
2016-12-20 13:31:46 +03:00
}
2017-01-05 20:06:24 +03:00
export const TestServiceService = {
2016-12-20 13:31:46 +03:00
testNoStream: {
path: '/test.TestService/TestNoStream',
requestStream: false,
responseStream: false,
2017-01-05 20:06:24 +03:00
requestType: pbFile.TestNoStreamRequest,
responseType: pbFile.TestNoStreamReply,
2016-12-20 13:31:46 +03:00
requestSerialize: serialize_test_TestNoStreamRequest,
requestDeserialize: deserialize_test_TestNoStreamRequest,
responseSerialize: serialize_test_TestNoStreamReply,
responseDeserialize: deserialize_test_TestNoStreamReply,
},
testStreamRequest: {
path: '/test.TestService/TestStreamRequest',
requestStream: true,
responseStream: false,
2017-01-05 20:06:24 +03:00
requestType: pbFile.TestStreamRequestRequest,
responseType: pbFile.TestStreamRequestReply,
2016-12-20 13:31:46 +03:00
requestSerialize: serialize_test_TestStreamRequestRequest,
requestDeserialize: deserialize_test_TestStreamRequestRequest,
responseSerialize: serialize_test_TestStreamRequestReply,
responseDeserialize: deserialize_test_TestStreamRequestReply,
},
testStreamReply: {
path: '/test.TestService/TestStreamReply',
requestStream: false,
responseStream: true,
2017-01-05 20:06:24 +03:00
requestType: pbFile.TestStreamReplyRequest,
responseType: pbFile.TestStreamReplyReply,
2016-12-20 13:31:46 +03:00
requestSerialize: serialize_test_TestStreamReplyRequest,
requestDeserialize: deserialize_test_TestStreamReplyRequest,
responseSerialize: serialize_test_TestStreamReplyReply,
responseDeserialize: deserialize_test_TestStreamReplyReply,
},
testStreamBoth: {
path: '/test.TestService/TestStreamBoth',
requestStream: true,
responseStream: true,
2017-01-05 20:06:24 +03:00
requestType: pbFile.TestStreamBothRequest,
responseType: pbFile.TestStreamBothReply,
2016-12-20 13:31:46 +03:00
requestSerialize: serialize_test_TestStreamBothRequest,
requestDeserialize: deserialize_test_TestStreamBothRequest,
responseSerialize: serialize_test_TestStreamBothReply,
responseDeserialize: deserialize_test_TestStreamBothReply,
},
}
2017-01-05 20:06:24 +03:00
export const TestServiceClient = grpc.makeGenericClientConstructor(TestServiceService)