mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-16 05:11:14 +01:00
333d9a4053
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import { SimpleRPC } from '../../src/extension/onboardDebug/node/copilotDebugWorker/rpc';
|
|
import { ChatFetchError } from '../../src/platform/chat/common/commonTypes';
|
|
import { createServiceIdentifier } from '../../src/util/common/services';
|
|
import { CachedTestInfo } from './cachingChatMLFetcher';
|
|
|
|
export const ISimulationEndpointHealth = createServiceIdentifier<ISimulationEndpointHealth>('ISimulationEndpointHealth');
|
|
|
|
export interface ISimulationEndpointHealth {
|
|
readonly _serviceBrand: undefined;
|
|
readonly failures: { testInfo: CachedTestInfo; request: ChatFetchError }[];
|
|
markFailure(testInfo: CachedTestInfo, failedRequest: ChatFetchError): void;
|
|
}
|
|
|
|
export class SimulationEndpointHealthImpl implements ISimulationEndpointHealth {
|
|
|
|
declare readonly _serviceBrand: undefined;
|
|
|
|
public readonly failures: { testInfo: CachedTestInfo; request: ChatFetchError }[] = [];
|
|
|
|
constructor() { }
|
|
|
|
markFailure(testInfo: CachedTestInfo, request: ChatFetchError) {
|
|
this.failures.push({ testInfo, request });
|
|
}
|
|
}
|
|
|
|
export class ProxiedSimulationEndpointHealth implements ISimulationEndpointHealth {
|
|
declare readonly _serviceBrand: undefined;
|
|
|
|
public readonly failures: { testInfo: CachedTestInfo; request: ChatFetchError }[] = [];
|
|
|
|
public static registerTo(instance: ISimulationEndpointHealth, rpc: SimpleRPC): ISimulationEndpointHealth {
|
|
rpc.registerMethod('ProxiedSimulationEndpointHealth.markFailure', ({ testInfo, request }) => {
|
|
instance.markFailure(testInfo, request);
|
|
});
|
|
return instance;
|
|
}
|
|
|
|
constructor(
|
|
private readonly rpc: SimpleRPC,
|
|
) { }
|
|
|
|
markFailure(testInfo: CachedTestInfo, request: ChatFetchError): void {
|
|
this.failures.push({ testInfo, request });
|
|
this.rpc.callMethod('ProxiedSimulationEndpointHealth.markFailure', { testInfo, request });
|
|
}
|
|
}
|