-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: command-specific configuration
- Loading branch information
Showing
73 changed files
with
628 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
export class DebugServerError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
public readonly cmd: string; | ||
public readonly args: string[]; | ||
public readonly output: string; | ||
|
||
constructor(options: { cmd: string; args: string[]; output: string }) { | ||
super(`Command "${options.cmd}" failed: ${options.output}`); | ||
this.name = 'DebugServerError'; | ||
this.cmd = options.cmd; | ||
this.args = options.args || []; | ||
this.output = options.output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { createConnection } from 'node:net'; | ||
import type { Executor } from './Executor.js'; | ||
|
||
type DebugServerExecutorOptions = { | ||
signal?: AbortSignal; | ||
}; | ||
|
||
export class DebugServerExecutor | ||
implements Executor<DebugServerExecutorOptions> | ||
{ | ||
#hostname: string; | ||
#port: number; | ||
#signal?: AbortSignal | undefined; | ||
|
||
constructor(options: { | ||
hostname: string; | ||
port: number; | ||
signal?: AbortSignal; | ||
}) { | ||
this.#hostname = options.hostname; | ||
this.#port = options.port; | ||
this.#signal = options.signal; | ||
} | ||
|
||
async execute( | ||
command: string, | ||
args: string[], | ||
config?: DebugServerExecutorOptions | ||
): Promise<string> { | ||
const signal = | ||
this.#signal && config?.signal | ||
? // @ts-ignore TS2339: Property 'any' does not exist on type 'typeof AbortSignal'. | ||
AbortSignal.any([this.#signal, config.signal]) | ||
: this.#signal || config?.signal; | ||
|
||
return new Promise((resolve, reject) => { | ||
const cmd = `${command} ${args.join(' ')}`.replace(/\s/g, ' ').trimEnd(); | ||
|
||
const client = createConnection( | ||
{ host: this.#hostname, port: this.#port, signal }, | ||
() => { | ||
client.write(`${cmd}\nq\n`); | ||
} | ||
); | ||
|
||
let chunks: Buffer[] = []; | ||
|
||
client.on('data', (chunk) => { | ||
chunks.push(chunk); | ||
}); | ||
|
||
client.on('end', () => { | ||
const response = Buffer.concat(chunks) | ||
.toString() | ||
.replace(/\r\n?/g, '\n'); | ||
|
||
const start = response.indexOf('\n>') + 2; | ||
const end = response.lastIndexOf('\n>'); | ||
resolve(response.slice(start, end).trim()); | ||
}); | ||
|
||
client.on('error', (error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface Executor<Config> { | ||
execute(command: string, args: string[], config?: Config): Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import type { Executor } from '../executors/Executor.ts'; | ||
import { execute } from '../internal/execute.js'; | ||
import type { Executor } from '../Executor.js'; | ||
import { execute, type Config } from '../internal/execute.js'; | ||
|
||
const pattern = /Done/; | ||
|
||
/** | ||
* Clear all caches that can affect channel launch time. | ||
*/ | ||
export async function clearLaunchCaches(executor: Executor): Promise<void> { | ||
await execute(executor, 'clear_launch_caches', [], [pattern]); | ||
export async function clearLaunchCaches<Context extends Executor<{}>>( | ||
ctx: Context, | ||
config?: Config<Context> | ||
): Promise<void> { | ||
await execute(ctx, 'clear_launch_caches', [], [pattern], config); | ||
} |
11 changes: 0 additions & 11 deletions
11
packages/debug-server/src/commands/clearSceneGraphPerformanceData.ts
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
packages/debug-server/src/commands/clearSceneGraphPerformanceMetrics.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Executor } from '../Executor.js'; | ||
import { execute, type Config } from '../internal/execute.js'; | ||
|
||
const pattern = /^\s*$/; | ||
|
||
/** | ||
* Clear SceneGraph node operation performance metrics. | ||
*/ | ||
export async function clearSceneGraphPerformanceMetrics< | ||
Context extends Executor<{}> | ||
>(ctx: Context, config?: Config<Context>): Promise<void> { | ||
await execute(ctx, 'sgperf', ['clear'], [pattern], config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
packages/debug-server/src/commands/disableRendezvousLogging.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import type { Executor } from '../executors/Executor.ts'; | ||
import { execute } from '../internal/execute.js'; | ||
import type { Executor } from '../Executor.js'; | ||
import { execute, type Config } from '../internal/execute.js'; | ||
|
||
const pattern = /rendezvous logging is off/; | ||
|
||
/** | ||
* Disable rendezvous logging. | ||
*/ | ||
export async function disableRendezvousLogging(executor: Executor): Promise<void> { | ||
await execute(executor, 'logrendezvous', ['off'], [pattern]); | ||
export async function disableRendezvousLogging<Context extends Executor<{}>>( | ||
ctx: Context, | ||
config?: Config<Context> | ||
): Promise<void> { | ||
await execute(ctx, 'logrendezvous', ['off'], [pattern], config); | ||
} |
Oops, something went wrong.