Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
],
"type": "module",
"exports": {
"./serve": "./dist/serve.js"
"./serve": "./dist/serve/serve.js"
},
"scripts": {
"dev": "ts-node src/index.ts",
"dev": "ts-node --esm src/main.ts serve",
"build": "rm -rf dist && tsc",
"format": "prettier --write 'src/**/*.ts'",
"format:check": "prettier --check 'src/**/*.ts'",
Expand Down
14 changes: 14 additions & 0 deletions src/grpc/discovery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import grpc = require('@grpc/grpc-js');
import { discovery1 } from '@cloudquery/plugin-pb-javascript';

export class DiscoveryServer extends discovery1.cloudquery.discovery.v1.UnimplementedDiscoveryService {
GetVersions(
call: grpc.ServerUnaryCall<
discovery1.cloudquery.discovery.v1.GetVersions.Request,
discovery1.cloudquery.discovery.v1.GetVersions.Response
>,
callback: grpc.sendUnaryData<discovery1.cloudquery.discovery.v1.GetVersions.Response>,
): void {
return callback(null, new discovery1.cloudquery.discovery.v1.GetVersions.Response({ versions: [3] }));
}
}
72 changes: 72 additions & 0 deletions src/grpc/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import grpc = require('@grpc/grpc-js');
import { pluginV3 } from '@cloudquery/plugin-pb-javascript';

export class PluginServer extends pluginV3.cloudquery.plugin.v3.UnimplementedPluginService {
GetName(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.GetName.Request,
pluginV3.cloudquery.plugin.v3.GetName.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.GetName.Response>,
): void {
throw new Error('Method not implemented.');
}
GetVersion(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.GetVersion.Request,
pluginV3.cloudquery.plugin.v3.GetVersion.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.GetVersion.Response>,
): void {
throw new Error('Method not implemented.');
}
Init(
call: grpc.ServerUnaryCall<pluginV3.cloudquery.plugin.v3.Init.Request, pluginV3.cloudquery.plugin.v3.Init.Response>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.Init.Response>,
): void {
throw new Error('Method not implemented.');
}
GetTables(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.GetTables.Request,
pluginV3.cloudquery.plugin.v3.GetTables.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.GetTables.Response>,
): void {
throw new Error('Method not implemented.');
}
Sync(
call: grpc.ServerWritableStream<
pluginV3.cloudquery.plugin.v3.Sync.Request,
pluginV3.cloudquery.plugin.v3.Sync.Response
>,
): void {
throw new Error('Method not implemented.');
}
Read(
call: grpc.ServerWritableStream<
pluginV3.cloudquery.plugin.v3.Read.Request,
pluginV3.cloudquery.plugin.v3.Read.Response
>,
): void {
throw new Error('Method not implemented.');
}
Write(
call: grpc.ServerReadableStream<
pluginV3.cloudquery.plugin.v3.Write.Request,
pluginV3.cloudquery.plugin.v3.Write.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.Write.Response>,
): void {
throw new Error('Method not implemented.');
}
Close(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.Close.Request,
pluginV3.cloudquery.plugin.v3.Close.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.Close.Response>,
): void {
throw new Error('Method not implemented.');
}
}
88 changes: 4 additions & 84 deletions src/grpc/server.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,8 @@
import { discovery1 } from '@cloudquery/plugin-pb-javascript';
import { pluginV3 } from '@cloudquery/plugin-pb-javascript';
import grpc = require('@grpc/grpc-js');

class DiscoveryServer extends discovery1.cloudquery.discovery.v1.UnimplementedDiscoveryService {
GetVersions(
call: grpc.ServerUnaryCall<
discovery1.cloudquery.discovery.v1.GetVersions.Request,
discovery1.cloudquery.discovery.v1.GetVersions.Response
>,
callback: grpc.sendUnaryData<discovery1.cloudquery.discovery.v1.GetVersions.Response>,
): void {
throw new Error('Method not implemented.');
}
}

class PluginServer extends pluginV3.cloudquery.plugin.v3.UnimplementedPluginService {
GetName(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.GetName.Request,
pluginV3.cloudquery.plugin.v3.GetName.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.GetName.Response>,
): void {
throw new Error('Method not implemented.');
}
GetVersion(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.GetVersion.Request,
pluginV3.cloudquery.plugin.v3.GetVersion.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.GetVersion.Response>,
): void {
throw new Error('Method not implemented.');
}
Init(
call: grpc.ServerUnaryCall<pluginV3.cloudquery.plugin.v3.Init.Request, pluginV3.cloudquery.plugin.v3.Init.Response>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.Init.Response>,
): void {
throw new Error('Method not implemented.');
}
GetTables(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.GetTables.Request,
pluginV3.cloudquery.plugin.v3.GetTables.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.GetTables.Response>,
): void {
throw new Error('Method not implemented.');
}
Sync(
call: grpc.ServerWritableStream<
pluginV3.cloudquery.plugin.v3.Sync.Request,
pluginV3.cloudquery.plugin.v3.Sync.Response
>,
): void {
throw new Error('Method not implemented.');
}
Read(
call: grpc.ServerWritableStream<
pluginV3.cloudquery.plugin.v3.Read.Request,
pluginV3.cloudquery.plugin.v3.Read.Response
>,
): void {
throw new Error('Method not implemented.');
}
Write(
call: grpc.ServerReadableStream<
pluginV3.cloudquery.plugin.v3.Write.Request,
pluginV3.cloudquery.plugin.v3.Write.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.Write.Response>,
): void {
throw new Error('Method not implemented.');
}
Close(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.Close.Request,
pluginV3.cloudquery.plugin.v3.Close.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.Close.Response>,
): void {
throw new Error('Method not implemented.');
}
}
import { pluginV3 } from '@cloudquery/plugin-pb-javascript';
import { discovery1 } from '@cloudquery/plugin-pb-javascript';
import { PluginServer } from './plugin.js';
import { DiscoveryServer } from './discovery.js';

export const getServer = () => {
const server = new grpc.Server();
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
import { serve } from './serve.js';
import { serve } from './serve/serve.js';

serve.parse();
File renamed without changes.
2 changes: 2 additions & 0 deletions src/serve.ts → src/serve/serve.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { startServer } from '../grpc/server.js';

const NETWORK_CHOICES = ['tcp', 'tcp4', 'tcp6', 'unix', 'unixpacket'] as const;
const LOG_LEVEL_CHOICES = ['trace', 'debug', 'info', 'warn', 'error'] as const;
Expand All @@ -24,6 +25,7 @@ export const serve = yargs(hideBin(process.argv))
() => {},
({ address, network, logLevel, logFormat, sentry: sentry, otelEndpoint, telemetryLevel }: ServeArgs) => {
console.log({ address, network, logLevel, logFormat, sentry, otelEndpoint, telemetryLevel });
startServer(address);
},
)
.options({
Expand Down