Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit bc34758

Browse files
committed
transport: add WriteCoalesceWaitTime to connConfig
1 parent abaf0c9 commit bc34758

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

transport/conn.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ type connWriter struct {
7070
connClose func()
7171

7272
// For use only when skipping sending a request.
73-
freeStream func(frame.StreamID)
74-
log log.Logger
73+
freeStream func(frame.StreamID)
74+
log log.Logger
75+
writeCoalesceWaitTime time.Duration
7576
}
7677

7778
func (c *connWriter) submit(r request) {
@@ -85,7 +86,7 @@ func (c *connWriter) loop(ctx context.Context) {
8586
// If there are no requests backoff.
8687
// Through experimentation, we know that, sleeping more than 1ms makes no difference or is counterproductive.
8788
if size == 0 {
88-
time.Sleep(time.Millisecond)
89+
time.Sleep(c.writeCoalesceWaitTime)
8990
size = len(c.requestCh)
9091
}
9192
if size == 0 {
@@ -333,11 +334,12 @@ type Conn struct {
333334
}
334335

335336
type ConnConfig struct {
336-
Username string
337-
Password string
338-
Keyspace string
339-
TCPNoDelay bool
340-
Timeout time.Duration
337+
Username string
338+
Password string
339+
Keyspace string
340+
TCPNoDelay bool
341+
WriteCoalesceWaitTime time.Duration
342+
Timeout time.Duration
341343

342344
// If not nil, all connections will use TLS according to TLSConfig,
343345
// please note that the default port (9042) may not support TLS.
@@ -356,16 +358,17 @@ type ConnConfig struct {
356358
func DefaultConnConfig(keyspace string) ConnConfig {
357359
l := log.NewDefaultLogger()
358360
return ConnConfig{
359-
Username: "cassandra",
360-
Password: "cassandra",
361-
Keyspace: keyspace,
362-
TCPNoDelay: true,
363-
Timeout: 500 * time.Millisecond,
364-
DefaultConsistency: frame.LOCALQUORUM,
365-
DefaultPort: "9042",
366-
ConnObserver: LoggingConnObserver{l},
367-
ComprBufferSize: comprBufferSize,
368-
Logger: l,
361+
Username: "cassandra",
362+
Password: "cassandra",
363+
Keyspace: keyspace,
364+
TCPNoDelay: true,
365+
Timeout: 500 * time.Millisecond,
366+
DefaultConsistency: frame.LOCALQUORUM,
367+
DefaultPort: "9042",
368+
ConnObserver: LoggingConnObserver{l},
369+
ComprBufferSize: comprBufferSize,
370+
Logger: l,
371+
WriteCoalesceWaitTime: time.Second,
369372
}
370373
}
371374

0 commit comments

Comments
 (0)