refactor: split native hotpath fallback and dispatch branches

This commit is contained in:
Tom Boucher
2026-05-04 20:24:36 -04:00
parent e0c791a5d0
commit 969cfcf998

View File

@@ -19,11 +19,25 @@ export class QueryNativeHotpathAdapter {
mode: 'json' | 'raw',
): Promise<unknown> {
if (!this.shouldUseNativeQuery()) {
return mode === 'raw'
? this.execRawFallback(legacyCommand, legacyArgs)
: this.execJsonFallback(legacyCommand, legacyArgs);
return this.dispatchFallback(legacyCommand, legacyArgs, mode);
}
return this.dispatchNative(legacyCommand, legacyArgs, registryCommand, registryArgs, mode);
}
private dispatchFallback(legacyCommand: string, legacyArgs: string[], mode: 'json' | 'raw'): Promise<unknown> {
return mode === 'raw'
? this.execRawFallback(legacyCommand, legacyArgs)
: this.execJsonFallback(legacyCommand, legacyArgs);
}
private dispatchNative(
legacyCommand: string,
legacyArgs: string[],
registryCommand: string,
registryArgs: string[],
mode: 'json' | 'raw',
): Promise<unknown> {
return mode === 'raw'
? this.nativeDirect.dispatchRaw(legacyCommand, legacyArgs, registryCommand, registryArgs)
: this.nativeDirect.dispatchJson(legacyCommand, legacyArgs, registryCommand, registryArgs);