Improve daemon RPC resiliency and diff handling
This commit is contained in:
+5
-5
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, test, vi } from "vitest";
|
||||
import { DaemonClientV2, type DaemonTransport } from "./daemon-client-v2";
|
||||
import { DaemonClient, type DaemonTransport } from "./daemon-client";
|
||||
|
||||
function createMockLogger() {
|
||||
return {
|
||||
@@ -49,8 +49,8 @@ function createMockTransport() {
|
||||
};
|
||||
}
|
||||
|
||||
describe("DaemonClientV2", () => {
|
||||
const clients: DaemonClientV2[] = [];
|
||||
describe("DaemonClient", () => {
|
||||
const clients: DaemonClient[] = [];
|
||||
|
||||
afterEach(async () => {
|
||||
for (const client of clients) {
|
||||
@@ -63,7 +63,7 @@ describe("DaemonClientV2", () => {
|
||||
const logger = createMockLogger();
|
||||
const mock = createMockTransport();
|
||||
|
||||
const client = new DaemonClientV2({
|
||||
const client = new DaemonClient({
|
||||
url: "ws://test",
|
||||
logger,
|
||||
reconnect: { enabled: false },
|
||||
@@ -150,7 +150,7 @@ describe("DaemonClientV2", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const client = new DaemonClientV2({
|
||||
const client = new DaemonClient({
|
||||
url: "ws://test",
|
||||
logger,
|
||||
reconnect: { enabled: false },
|
||||
+3
-3
@@ -139,7 +139,7 @@ export type DaemonEvent =
|
||||
|
||||
export type DaemonEventHandler = (event: DaemonEvent) => void;
|
||||
|
||||
export type DaemonClientV2Config = {
|
||||
export type DaemonClientConfig = {
|
||||
url: string;
|
||||
authHeader?: string;
|
||||
suppressSendErrors?: boolean;
|
||||
@@ -256,7 +256,7 @@ interface PendingSend {
|
||||
timeoutHandle: ReturnType<typeof setTimeout>;
|
||||
}
|
||||
|
||||
export class DaemonClientV2 {
|
||||
export class DaemonClient {
|
||||
private transport: DaemonTransport | null = null;
|
||||
private transportCleanup: Array<() => void> = [];
|
||||
private rawMessageListeners: Set<(message: SessionOutboundMessage) => void> = new Set();
|
||||
@@ -285,7 +285,7 @@ export class DaemonClientV2 {
|
||||
private logger: Logger;
|
||||
private pendingSendQueue: PendingSend[] = [];
|
||||
|
||||
constructor(private config: DaemonClientV2Config) {
|
||||
constructor(private config: DaemonClientConfig) {
|
||||
this.logger = config.logger ?? consoleLogger;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user