File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import { KAFKA, KAFKA_PRODUCER } from 'lib/db';
44import * as tls from 'tls' ;
55
66const log = debug ( 'umami:kafka' ) ;
7+ const CONNECT_TIMEOUT = 5000 ;
8+ const SEND_TIMEOUT = 3000 ;
9+ const ACKS = 1 ;
710
811let kafka : Kafka ;
912let producer : Producer ;
@@ -31,7 +34,7 @@ function getClient() {
3134 const client : Kafka = new Kafka ( {
3235 clientId : 'umami' ,
3336 brokers : brokers ,
34- connectionTimeout : 3000 ,
37+ connectionTimeout : CONNECT_TIMEOUT ,
3538 logLevel : logLevel . ERROR ,
3639 ...ssl ,
3740 } ) ;
@@ -71,7 +74,8 @@ async function sendMessage(
7174 value : JSON . stringify ( message ) ,
7275 } ,
7376 ] ,
74- acks : 1 ,
77+ timeout : SEND_TIMEOUT ,
78+ acks : ACKS ,
7579 } ) ;
7680}
7781
@@ -83,7 +87,8 @@ async function sendMessages(topic: string, messages: { [key: string]: string | n
8387 messages : messages . map ( a => {
8488 return { value : JSON . stringify ( a ) } ;
8589 } ) ,
86- acks : 1 ,
90+ timeout : SEND_TIMEOUT ,
91+ acks : ACKS ,
8792 } ) ;
8893}
8994
You can’t perform that action at this time.
0 commit comments