Skip to content

Commit 2c79413

Browse files
committed
Initial: Clear out compilation commands for multiple reflection protocols
1 parent ecc52a2 commit 2c79413

File tree

11 files changed

+2582
-47
lines changed

11 files changed

+2582
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"prepare": "yarn run compile",
4545
"pretest": "yarn run compile && yarn run fix",
4646
"posttest": "yarn run check",
47-
"protoc": "grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./src --grpc_out=grpc_js:./src --ts_out=grpc_js:./src --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts -I ./static/grpc/reflection/v1alpha reflection.proto",
47+
"protoc": "node scripts/compile-protoc",
4848
"build": "yarn run compile && yarn run fix && yarn run check"
4949
},
5050
"files": [

scripts/compile-protoc.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const fs = require('fs');
2+
const {execSync} = require('child_process');
3+
4+
const supportedProtocols = ['v1alpha', 'v1'];
5+
6+
async function main() {
7+
for (const protocol of supportedProtocols) {
8+
if (fs.existsSync(`./src/reflection_providers/${protocol}`)) {
9+
fs.rmdirSync(`./src/reflection_providers/${protocol}`, {recursive: true});
10+
}
11+
12+
fs.mkdirSync(`./src/reflection_providers/${protocol}`);
13+
14+
console.log(
15+
`Compiling protocol buffers and building services + clients for protocol: ${protocol}...\n`
16+
);
17+
18+
const command = [
19+
'grpc_tools_node_protoc',
20+
`--js_out=import_style=commonjs,binary:./src/reflection_providers/${protocol}`,
21+
`--grpc_out=grpc_js:./src/reflection_providers/${protocol}`,
22+
`--ts_out=grpc_js:./src/reflection_providers/${protocol}`,
23+
'--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts',
24+
`-I ./static/grpc/reflection/${protocol}`,
25+
'reflection.proto',
26+
].join(' ');
27+
28+
execSync(command, {stdio: 'inherit'});
29+
30+
console.log('Compilation done for', protocol, '\n');
31+
}
32+
33+
console.log('Protocol buffers compilation completed.');
34+
}
35+
36+
main().catch(err => {
37+
console.error('Error during protocol buffers compilation:');
38+
39+
throw err;
40+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// package: grpc.reflection.v1
2+
// file: reflection.proto
3+
4+
/* tslint:disable */
5+
/* eslint-disable */
6+
7+
import * as grpc from "@postman/grpc-js";
8+
import * as reflection_pb from "./reflection_pb";
9+
10+
interface IServerReflectionService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
11+
serverReflectionInfo: IServerReflectionService_IServerReflectionInfo;
12+
}
13+
14+
interface IServerReflectionService_IServerReflectionInfo extends grpc.MethodDefinition<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse> {
15+
path: "/grpc.reflection.v1.ServerReflection/ServerReflectionInfo";
16+
requestStream: true;
17+
responseStream: true;
18+
requestSerialize: grpc.serialize<reflection_pb.ServerReflectionRequest>;
19+
requestDeserialize: grpc.deserialize<reflection_pb.ServerReflectionRequest>;
20+
responseSerialize: grpc.serialize<reflection_pb.ServerReflectionResponse>;
21+
responseDeserialize: grpc.deserialize<reflection_pb.ServerReflectionResponse>;
22+
}
23+
24+
export const ServerReflectionService: IServerReflectionService;
25+
26+
export interface IServerReflectionServer extends grpc.UntypedServiceImplementation {
27+
serverReflectionInfo: grpc.handleBidiStreamingCall<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse>;
28+
}
29+
30+
export interface IServerReflectionClient {
31+
serverReflectionInfo(): grpc.ClientDuplexStream<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse>;
32+
serverReflectionInfo(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse>;
33+
serverReflectionInfo(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse>;
34+
}
35+
36+
export class ServerReflectionClient extends grpc.Client implements IServerReflectionClient {
37+
constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial<grpc.ClientOptions>);
38+
public serverReflectionInfo(options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse>;
39+
public serverReflectionInfo(metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<reflection_pb.ServerReflectionRequest, reflection_pb.ServerReflectionResponse>;
40+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// GENERATED CODE -- DO NOT EDIT!
2+
3+
// Original file comments:
4+
// Copyright 2016 The gRPC Authors
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Service exported by server reflection. A more complete description of how
19+
// server reflection works can be found at
20+
// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
21+
//
22+
// The canonical version of this proto can be found at
23+
// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto
24+
//
25+
'use strict';
26+
var grpc = require('@postman/grpc-js');
27+
var reflection_pb = require('./reflection_pb.js');
28+
29+
function serialize_grpc_reflection_v1_ServerReflectionRequest(arg) {
30+
if (!(arg instanceof reflection_pb.ServerReflectionRequest)) {
31+
throw new Error('Expected argument of type grpc.reflection.v1.ServerReflectionRequest');
32+
}
33+
return Buffer.from(arg.serializeBinary());
34+
}
35+
36+
function deserialize_grpc_reflection_v1_ServerReflectionRequest(buffer_arg) {
37+
return reflection_pb.ServerReflectionRequest.deserializeBinary(new Uint8Array(buffer_arg));
38+
}
39+
40+
function serialize_grpc_reflection_v1_ServerReflectionResponse(arg) {
41+
if (!(arg instanceof reflection_pb.ServerReflectionResponse)) {
42+
throw new Error('Expected argument of type grpc.reflection.v1.ServerReflectionResponse');
43+
}
44+
return Buffer.from(arg.serializeBinary());
45+
}
46+
47+
function deserialize_grpc_reflection_v1_ServerReflectionResponse(buffer_arg) {
48+
return reflection_pb.ServerReflectionResponse.deserializeBinary(new Uint8Array(buffer_arg));
49+
}
50+
51+
52+
var ServerReflectionService = exports.ServerReflectionService = {
53+
// The reflection service is structured as a bidirectional stream, ensuring
54+
// all related requests go to a single server.
55+
serverReflectionInfo: {
56+
path: '/grpc.reflection.v1.ServerReflection/ServerReflectionInfo',
57+
requestStream: true,
58+
responseStream: true,
59+
requestType: reflection_pb.ServerReflectionRequest,
60+
responseType: reflection_pb.ServerReflectionResponse,
61+
requestSerialize: serialize_grpc_reflection_v1_ServerReflectionRequest,
62+
requestDeserialize: deserialize_grpc_reflection_v1_ServerReflectionRequest,
63+
responseSerialize: serialize_grpc_reflection_v1_ServerReflectionResponse,
64+
responseDeserialize: deserialize_grpc_reflection_v1_ServerReflectionResponse,
65+
},
66+
};
67+
68+
exports.ServerReflectionClient = grpc.makeGenericClientConstructor(ServerReflectionService, 'ServerReflection');

0 commit comments

Comments
 (0)