Skip to content

Commit 2808bdb

Browse files
committed
add loggin and retry
1 parent deaa6c3 commit 2808bdb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/db/src/clickhouse/client.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ type WarnLogParams = LogParams & { err?: Error };
2424

2525
class CustomLogger implements Logger {
2626
trace({ message, args }: LogParams) {
27-
logger.debug(message, args);
27+
logger.info(message, args);
2828
}
2929
debug({ message, args }: LogParams) {
30-
if (message.includes('Query:') && args?.response_status === 200) {
31-
return;
32-
}
33-
logger.debug(message, args);
30+
logger.info(message, args);
3431
}
3532
info({ message, args }: LogParams) {
3633
logger.info(message, args);
@@ -89,7 +86,7 @@ const cleanQuery = (query?: string) =>
8986
? query.replace(/\n/g, '').replace(/\s+/g, ' ').trim()
9087
: undefined;
9188

92-
async function withRetry<T>(
89+
export async function withRetry<T>(
9390
operation: () => Promise<T>,
9491
maxRetries = 3,
9592
baseDelay = 500,
@@ -157,6 +154,13 @@ export const ch = new Proxy(originalCh, {
157154
});
158155
}
159156

157+
if (property === 'command') {
158+
return (...args: any[]) =>
159+
withRetry(() => {
160+
return value.apply(target, args);
161+
});
162+
}
163+
160164
return value;
161165
},
162166
});

0 commit comments

Comments
 (0)