Skip to content

Commit 14a4183

Browse files
committed
Some fixes and cleanups
1 parent 3c50bfe commit 14a4183

File tree

9 files changed

+35
-390
lines changed

9 files changed

+35
-390
lines changed

.configs/prometheus.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

internal-packages/clickhouse/src/client/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export class ClickhouseClient implements ClickhouseReader, ClickhouseWriter {
4848
this.tracer = config.tracer ?? trace.getTracer("@internal/clickhouse");
4949
}
5050

51+
public async close() {
52+
await this.client.close();
53+
}
54+
5155
public query<TIn extends z.ZodSchema<any>, TOut extends z.ZodSchema<any>>(req: {
5256
/**
5357
* The name of the operation.

internal-packages/clickhouse/src/client/noop.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { z } from "zod";
66
import { ClickHouseSettings, InsertResult } from "@clickhouse/client";
77

88
export class NoopClient implements ClickhouseReader, ClickhouseWriter {
9+
public async close() {
10+
return;
11+
}
12+
913
public query<TIn extends z.ZodSchema<any>, TOut extends z.ZodSchema<any>>(req: {
1014
query: string;
1115
params?: TIn;

internal-packages/clickhouse/src/client/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export interface ClickhouseReader {
4141
*/
4242
settings?: ClickHouseSettings;
4343
}): ClickhouseQueryFunction<z.input<TIn>, z.output<TOut>>;
44+
45+
close(): Promise<void>;
4446
}
4547

4648
export type ClickhouseInsertFunction<TInput> = (
@@ -58,4 +60,6 @@ export interface ClickhouseWriter {
5860
schema: TSchema;
5961
settings?: ClickHouseSettings;
6062
}): ClickhouseInsertFunction<z.input<TSchema>>;
63+
64+
close(): Promise<void>;
6165
}

internal-packages/clickhouse/src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class ClickHouse {
3131
public readonly reader: ClickhouseReader;
3232
public readonly writer: ClickhouseWriter;
3333
private readonly logger: Logger;
34+
private _splitClients: boolean;
3435

3536
constructor(config: ClickHouseConfig) {
3637
this.logger = config.logger ?? new Logger("ClickHouse", "debug");
@@ -49,6 +50,8 @@ export class ClickHouse {
4950
});
5051
this.reader = client;
5152
this.writer = client;
53+
54+
this._splitClients = false;
5255
} else if (config.writerUrl && config.readerUrl) {
5356
this.reader = new ClickhouseClient({
5457
name: config.readerName ?? "clickhouse-reader",
@@ -62,9 +65,13 @@ export class ClickHouse {
6265
clickhouseSettings: config.clickhouseSettings,
6366
logger: this.logger,
6467
});
68+
69+
this._splitClients = true;
6570
} else {
6671
this.reader = new NoopClient();
6772
this.writer = new NoopClient();
73+
74+
this._splitClients = true;
6875
}
6976
}
7077

@@ -87,6 +94,14 @@ export class ClickHouse {
8794
});
8895
}
8996

97+
async close() {
98+
if (this._splitClients) {
99+
await Promise.all([this.reader.close(), this.writer.close()]);
100+
} else {
101+
await this.reader.close();
102+
}
103+
}
104+
90105
get taskRuns() {
91106
return {
92107
insert: insertTaskRuns(this.writer),
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from "./client.js";
22
export * from "./errors.js";
3-
export * from "./stream.js";
43
export type * from "./pgoutput.js";

internal-packages/replication/src/stream.test.ts

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)