2016-12-13 19:10:02 +01:00
|
|
|
// GENERATED CODE -- DO NOT EDIT!
|
2016-12-16 16:24:05 +01:00
|
|
|
{{$Package:=.File.Package}}
|
2016-12-13 19:10:02 +01:00
|
|
|
'use strict';
|
|
|
|
var grpc = require('grpc');
|
2016-12-19 15:21:28 +01:00
|
|
|
var {{$Package}}_pb = require('./{{$Package}}_pb.js');
|
2016-12-20 11:31:46 +01:00
|
|
|
|
2016-12-19 15:21:28 +01:00
|
|
|
{{range .File.Service}}{{range .Method}}
|
2016-12-16 16:08:37 +01:00
|
|
|
function serialize_{{$Package}}_{{.InputType | splitArray "." | last}}(arg) {
|
2016-12-19 15:21:28 +01:00
|
|
|
if (!(arg instanceof {{$Package}}_pb.{{.InputType | splitArray "." | last}})) {
|
2016-12-16 16:08:37 +01:00
|
|
|
throw new Error('Expected argument of type {{$Package}}.{{.InputType | splitArray "." | last}}');
|
|
|
|
}
|
|
|
|
return new Buffer(arg.serializeBinary());
|
2016-12-13 19:10:02 +01:00
|
|
|
}
|
|
|
|
|
2016-12-16 16:08:37 +01:00
|
|
|
function deserialize_{{$Package}}_{{.InputType | splitArray "." | last}}(buffer_arg) {
|
2016-12-19 15:21:28 +01:00
|
|
|
return {{$Package}}_pb.{{.InputType | splitArray "." | last}}.deserializeBinary(new Uint8Array(buffer_arg));
|
2016-12-13 19:10:02 +01:00
|
|
|
}
|
|
|
|
|
2016-12-16 16:08:37 +01:00
|
|
|
function serialize_{{$Package}}_{{.OutputType | splitArray "." | last}}(arg) {
|
2016-12-19 15:21:28 +01:00
|
|
|
if (!(arg instanceof {{$Package}}_pb.{{.OutputType | splitArray "." | last}})) {
|
2016-12-16 16:08:37 +01:00
|
|
|
throw new Error('Expected argument of type {{$Package}}.{{.OutputType | splitArray "." | last}}');
|
|
|
|
}
|
|
|
|
return new Buffer(arg.serializeBinary());
|
2016-12-13 19:10:02 +01:00
|
|
|
}
|
|
|
|
|
2016-12-16 16:08:37 +01:00
|
|
|
function deserialize_{{$Package}}_{{.OutputType | splitArray "." | last}}(buffer_arg) {
|
2016-12-19 15:21:28 +01:00
|
|
|
return {{$Package}}_pb.{{.OutputType | splitArray "." | last}}.deserializeBinary(new Uint8Array(buffer_arg));
|
2016-12-20 11:31:46 +01:00
|
|
|
}
|
|
|
|
{{end}}{{end}}
|
2016-12-16 16:08:37 +01:00
|
|
|
{{range .File.Service}}
|
|
|
|
var {{.Name}}Service = exports.{{.Name}}Service = {
|
2016-12-20 11:31:46 +01:00
|
|
|
{{$serviceName:=.Name}}
|
|
|
|
{{range .Method}}{{.Name | lowerCamelCase}}: {
|
2016-12-16 16:08:37 +01:00
|
|
|
path: '/{{$Package}}.{{$serviceName}}/{{.Name}}',
|
|
|
|
requestStream: {{.ClientStreaming | default "false"}},
|
|
|
|
responseStream: {{.ServerStreaming | default "false"}},
|
2016-12-19 15:21:28 +01:00
|
|
|
requestType: {{$Package}}_pb.{{.InputType | splitArray "." | last}},
|
|
|
|
responseType: {{$Package}}_pb.{{.OutputType | splitArray "." | last}},
|
2016-12-16 16:08:37 +01:00
|
|
|
requestSerialize: serialize_{{$Package}}_{{.InputType | splitArray "." | last}},
|
|
|
|
requestDeserialize: deserialize_{{$Package}}_{{.InputType | splitArray "." | last}},
|
|
|
|
responseSerialize: serialize_{{$Package}}_{{.OutputType | splitArray "." | last}},
|
|
|
|
responseDeserialize: deserialize_{{$Package}}_{{.OutputType | splitArray "." | last}},
|
2016-12-20 11:31:46 +01:00
|
|
|
},
|
|
|
|
{{end}}
|
2016-12-16 16:08:37 +01:00
|
|
|
}
|
|
|
|
|
2016-12-19 15:21:28 +01:00
|
|
|
exports.{{.Name}}Client = grpc.makeGenericClientConstructor({{.Name}}Service);{{end}}
|