refactor: split native hotpath fallback and dispatch branches
This commit is contained in:
@@ -19,11 +19,25 @@ export class QueryNativeHotpathAdapter {
|
|||||||
mode: 'json' | 'raw',
|
mode: 'json' | 'raw',
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
if (!this.shouldUseNativeQuery()) {
|
if (!this.shouldUseNativeQuery()) {
|
||||||
return mode === 'raw'
|
return this.dispatchFallback(legacyCommand, legacyArgs, mode);
|
||||||
? this.execRawFallback(legacyCommand, legacyArgs)
|
|
||||||
: this.execJsonFallback(legacyCommand, legacyArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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'
|
return mode === 'raw'
|
||||||
? this.nativeDirect.dispatchRaw(legacyCommand, legacyArgs, registryCommand, registryArgs)
|
? this.nativeDirect.dispatchRaw(legacyCommand, legacyArgs, registryCommand, registryArgs)
|
||||||
: this.nativeDirect.dispatchJson(legacyCommand, legacyArgs, registryCommand, registryArgs);
|
: this.nativeDirect.dispatchJson(legacyCommand, legacyArgs, registryCommand, registryArgs);
|
||||||
|
|||||||
Reference in New Issue
Block a user