refactor: deepen GSDTools query execution seams (#3085)
* refactor: deepen gsdtools query execution seams * docs: add changeset for query seam deepening * docs: fix changeset summary text * fix: address coderabbit query seam findings * test: address remaining coderabbit findings and notes * refactor: use internal gsdtools error type import
This commit is contained in:
31
sdk/src/query-native-hotpath-adapter.ts
Normal file
31
sdk/src/query-native-hotpath-adapter.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { QueryNativeDirectAdapter } from './query-native-direct-adapter.js';
|
||||
|
||||
/**
|
||||
* Adapter Module for runner hot-path native commands.
|
||||
*/
|
||||
export class QueryNativeHotpathAdapter {
|
||||
constructor(
|
||||
private readonly shouldUseNativeQuery: () => boolean,
|
||||
private readonly nativeDirect: QueryNativeDirectAdapter,
|
||||
private readonly execJsonFallback: (legacyCommand: string, legacyArgs: string[]) => Promise<unknown>,
|
||||
private readonly execRawFallback: (legacyCommand: string, legacyArgs: string[]) => Promise<string>,
|
||||
) {}
|
||||
|
||||
async dispatch(
|
||||
legacyCommand: string,
|
||||
legacyArgs: string[],
|
||||
registryCommand: string,
|
||||
registryArgs: string[],
|
||||
mode: 'json' | 'raw',
|
||||
): Promise<unknown> {
|
||||
if (!this.shouldUseNativeQuery()) {
|
||||
return mode === 'raw'
|
||||
? this.execRawFallback(legacyCommand, legacyArgs)
|
||||
: this.execJsonFallback(legacyCommand, legacyArgs);
|
||||
}
|
||||
|
||||
return mode === 'raw'
|
||||
? this.nativeDirect.dispatchRaw(legacyCommand, legacyArgs, registryCommand, registryArgs)
|
||||
: this.nativeDirect.dispatchJson(legacyCommand, legacyArgs, registryCommand, registryArgs);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user