Skip to content

fix(deps): Update dependency @cloudquery/plugin-pb-javascript to ^0.0.19 #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2024
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
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
},
"dependencies": {
"@apache-arrow/esnext-esm": "^12.0.1",
"@cloudquery/plugin-pb-javascript": "^0.0.18",
"@cloudquery/plugin-pb-javascript": "^0.0.19",
"@grpc/grpc-js": "^1.9.0",
"@types/luxon": "^3.3.1",
"ajv": "^8.12.0",
Expand Down
50 changes: 50 additions & 0 deletions src/grpc/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,54 @@ export class PluginServer extends pluginV3.cloudquery.plugin.v3.UnimplementedPlu
return callback(error, null);
});
}

TestConnection(
call: grpc.ServerUnaryCall<
pluginV3.cloudquery.plugin.v3.TestConnection.Request,
pluginV3.cloudquery.plugin.v3.TestConnection.Response
>,
callback: grpc.sendUnaryData<pluginV3.cloudquery.plugin.v3.TestConnection.Response>,
): void {
const { spec = new Uint8Array() } = call.request.toObject();

const stringSpec = new TextDecoder().decode(spec);
if (this.plugin.testConnection) {
this.plugin
.testConnection(stringSpec)
.then(({ success, failureCode, failureDescription }) => {
// eslint-disable-next-line promise/no-callback-in-promise
return callback(
null,
new pluginV3.cloudquery.plugin.v3.TestConnection.Response({
success,
failure_code: failureCode,
failure_description: failureDescription,
}),
);
})
.catch((error) => {
// eslint-disable-next-line promise/no-callback-in-promise
return callback(error, null);
});
} else {
// fall back to init
this.plugin
.init(stringSpec, { noConnection: false })
.then(() => {
// eslint-disable-next-line promise/no-callback-in-promise
return callback(null, new pluginV3.cloudquery.plugin.v3.TestConnection.Response({ success: true }));
})
.catch(() => {
// eslint-disable-next-line promise/no-callback-in-promise
return callback(
null,
new pluginV3.cloudquery.plugin.v3.TestConnection.Response({
success: false,
failure_code: 'UNKNOWN',
failure_description: 'Failed to connect',
}),
);
});
}
}
}
1 change: 1 addition & 0 deletions src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface Plugin extends Client {
dockerFile: () => string;
buildTargets: () => BuildTarget[];
init: (spec: string, options: NewClientOptions) => Promise<void>;
testConnection?: (spec: string) => Promise<{ success?: boolean; failureCode?: string; failureDescription?: string }>;
}

export const newUnimplementedSource = (): SourceClient => {
Expand Down