mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
fix(cassandra): shorten the read timeout below the rpc deadline (#2198)
This commit is contained in:
@@ -7,7 +7,10 @@ import cassandra from 'cassandra-driver';
|
||||
const distance = cassandra.types.distance;
|
||||
|
||||
const MAX_REQUESTS_PER_CONNECTION = 2048;
|
||||
const READ_TIMEOUT_MS = 12000;
|
||||
const CONNECT_TIMEOUT_MS = 5000;
|
||||
const DEFAULT_READ_TIMEOUT_MS = 5000;
|
||||
|
||||
export const BACKGROUND_READ_TIMEOUT_MS = 12000;
|
||||
|
||||
interface CassandraConfig {
|
||||
hosts: Array<string>;
|
||||
@@ -16,6 +19,7 @@ interface CassandraConfig {
|
||||
localDc: string;
|
||||
username?: string | undefined;
|
||||
password?: string | undefined;
|
||||
readTimeoutMs?: number | undefined;
|
||||
}
|
||||
|
||||
interface CassandraClientOptions {
|
||||
@@ -66,6 +70,7 @@ class CassandraClient implements ICassandraClient {
|
||||
localDc: config.localDc,
|
||||
username: config.username,
|
||||
password: config.password,
|
||||
readTimeoutMs: config.readTimeoutMs,
|
||||
};
|
||||
this.logger = options.logger ?? NoopLogger;
|
||||
this.client = null;
|
||||
@@ -93,7 +98,8 @@ class CassandraClient implements ICassandraClient {
|
||||
},
|
||||
},
|
||||
socketOptions: {
|
||||
readTimeout: READ_TIMEOUT_MS,
|
||||
connectTimeout: CONNECT_TIMEOUT_MS,
|
||||
readTimeout: this.config.readTimeoutMs ?? DEFAULT_READ_TIMEOUT_MS,
|
||||
},
|
||||
encoding: {
|
||||
map: Map,
|
||||
|
||||
Reference in New Issue
Block a user