Skip to content

Commit d5c5513

Browse files
committed
address linter complaints
1 parent 9492180 commit d5c5513

File tree

13 files changed

+486
-93
lines changed

13 files changed

+486
-93
lines changed

cluster_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ func TestNewCluster_Defaults(t *testing.T) {
4646
assertEqual(t, "cluster config reconnect interval", 60*time.Second, cfg.ReconnectInterval)
4747
assertTrue(t, "cluster config conviction policy",
4848
reflect.DeepEqual(&SimpleConvictionPolicy{}, cfg.ConvictionPolicy))
49-
assertTrue(t, "cluster config reconnection policy",
50-
reflect.DeepEqual(&ConstantReconnectionPolicy{MaxRetries: 3, Interval: 1 * time.Second}, cfg.ReconnectionPolicy))
49+
assertTrue(
50+
t,
51+
"cluster config reconnection policy",
52+
reflect.DeepEqual(
53+
&ConstantReconnectionPolicy{MaxRetries: 3, Interval: 1 * time.Second},
54+
cfg.ReconnectionPolicy,
55+
),
56+
)
5157
}
5258

5359
func TestNewCluster_WithHosts(t *testing.T) {

common_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ import (
4040
)
4141

4242
var (
43-
flagCluster = flag.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples")
44-
flagProto = flag.Int("proto", 0, "protcol version")
45-
flagCQL = flag.String("cql", "3.0.0", "CQL version")
46-
flagRF = flag.Int("rf", 1, "replication factor for test keyspace")
47-
clusterSize = flag.Int("clusterSize", 1, "the expected size of the cluster")
48-
flagRetry = flag.Int("retries", 5, "number of times to retry queries")
49-
flagAutoWait = flag.Duration("autowait", 1000*time.Millisecond, "time to wait for autodiscovery to fill the hosts poll")
43+
flagCluster = flag.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples")
44+
flagProto = flag.Int("proto", 0, "protcol version")
45+
flagCQL = flag.String("cql", "3.0.0", "CQL version")
46+
flagRF = flag.Int("rf", 1, "replication factor for test keyspace")
47+
clusterSize = flag.Int("clusterSize", 1, "the expected size of the cluster")
48+
flagRetry = flag.Int("retries", 5, "number of times to retry queries")
49+
flagAutoWait = flag.Duration(
50+
"autowait",
51+
1000*time.Millisecond,
52+
"time to wait for autodiscovery to fill the hosts poll",
53+
)
5054
flagRunSslTest = flag.Bool("runssl", false, "Set to true to run ssl test")
5155
flagRunAuthTest = flag.Bool("runauth", false, "Set to true to run authentication test")
5256
flagCompressTest = flag.String("compressor", "no-compression", "compressor to use")

conn.go

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ func (s *Session) connect(ctx context.Context, host *HostInfo, errorHandler Conn
217217
}
218218

219219
// dial establishes a connection to a Cassandra node and notifies the session's connectObserver.
220-
func (s *Session) dial(ctx context.Context, host *HostInfo, connConfig *ConnConfig, errorHandler ConnErrorHandler) (*Conn, error) {
220+
func (s *Session) dial(
221+
ctx context.Context,
222+
host *HostInfo,
223+
connConfig *ConnConfig,
224+
errorHandler ConnErrorHandler,
225+
) (*Conn, error) {
221226
var obs ObservedConnect
222227
if s.connectObserver != nil {
223228
obs.Host = host
@@ -238,7 +243,12 @@ func (s *Session) dial(ctx context.Context, host *HostInfo, connConfig *ConnConf
238243
// dialWithoutObserver establishes connection to a Cassandra node.
239244
//
240245
// dialWithoutObserver does not notify the connection observer, so you most probably want to call dial() instead.
241-
func (s *Session) dialWithoutObserver(ctx context.Context, host *HostInfo, cfg *ConnConfig, errorHandler ConnErrorHandler) (*Conn, error) {
246+
func (s *Session) dialWithoutObserver(
247+
ctx context.Context,
248+
host *HostInfo,
249+
cfg *ConnConfig,
250+
errorHandler ConnErrorHandler,
251+
) (*Conn, error) {
242252
dialedHost, err := cfg.HostDialer.DialHost(ctx, host)
243253
if err != nil {
244254
return nil, err
@@ -385,7 +395,11 @@ func (s *startupCoordinator) setupConn(ctx context.Context) error {
385395
return nil
386396
}
387397

388-
func (s *startupCoordinator) write(ctx context.Context, frame frameBuilder, startupCompleted *atomic.Bool) (frame, error) {
398+
func (s *startupCoordinator) write(
399+
ctx context.Context,
400+
frame frameBuilder,
401+
startupCompleted *atomic.Bool,
402+
) (frame, error) {
389403
select {
390404
case s.frameTicker <- struct{}{}:
391405
case <-ctx.Done():
@@ -414,7 +428,11 @@ func (s *startupCoordinator) options(ctx context.Context, startupCompleted *atom
414428
return s.startup(ctx, supported.supported, startupCompleted)
415429
}
416430

417-
func (s *startupCoordinator) startup(ctx context.Context, supported map[string][]string, startupCompleted *atomic.Bool) error {
431+
func (s *startupCoordinator) startup(
432+
ctx context.Context,
433+
supported map[string][]string,
434+
startupCompleted *atomic.Bool,
435+
) error {
418436
m := map[string]string{
419437
"CQL_VERSION": s.conn.cfg.CQLVersion,
420438
"DRIVER_NAME": driverName,
@@ -457,7 +475,11 @@ func (s *startupCoordinator) startup(ctx context.Context, supported map[string][
457475
}
458476
}
459477

460-
func (s *startupCoordinator) authenticateHandshake(ctx context.Context, authFrame *authenticateFrame, startupCompleted *atomic.Bool) error {
478+
func (s *startupCoordinator) authenticateHandshake(
479+
ctx context.Context,
480+
authFrame *authenticateFrame,
481+
startupCompleted *atomic.Bool,
482+
) error {
461483
if s.conn.auth == nil {
462484
return fmt.Errorf("authentication required (using %q)", authFrame.class)
463485
}
@@ -1177,7 +1199,12 @@ func (c *Conn) exec(ctx context.Context, req frameBuilder, tracer Tracer) (*fram
11771199
return c.execInternal(ctx, req, tracer, true)
11781200
}
11791201

1180-
func (c *Conn) execInternal(ctx context.Context, req frameBuilder, tracer Tracer, startupCompleted bool) (*framer, error) {
1202+
func (c *Conn) execInternal(
1203+
ctx context.Context,
1204+
req frameBuilder,
1205+
tracer Tracer,
1206+
startupCompleted bool,
1207+
) (*framer, error) {
11811208
if ctxErr := ctx.Err(); ctxErr != nil {
11821209
return nil, ctxErr
11831210
}
@@ -1394,7 +1421,12 @@ type inflightPrepare struct {
13941421
preparedStatment *preparedStatment
13951422
}
13961423

1397-
func (c *Conn) prepareStatement(ctx context.Context, stmt string, tracer Tracer, keyspace string) (*preparedStatment, error) {
1424+
func (c *Conn) prepareStatement(
1425+
ctx context.Context,
1426+
stmt string,
1427+
tracer Tracer,
1428+
keyspace string,
1429+
) (*preparedStatment, error) {
13981430
stmtCacheKey := c.session.stmtsLRU.keyFor(c.host.HostID(), keyspace, stmt)
13991431
flight, ok := c.session.stmtsLRU.execIfMissing(stmtCacheKey, func(lru *lru.Cache) *inflightPrepare {
14001432
flight := &inflightPrepare{
@@ -1546,7 +1578,9 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) *Iter {
15461578
}
15471579

15481580
if len(values) != info.request.actualColCount {
1549-
return &Iter{err: fmt.Errorf("gocql: expected %d values send got %d", info.request.actualColCount, len(values))}
1581+
return &Iter{
1582+
err: fmt.Errorf("gocql: expected %d values send got %d", info.request.actualColCount, len(values)),
1583+
}
15501584
}
15511585

15521586
params.values = make([]queryValues, len(values))
@@ -1560,7 +1594,8 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) *Iter {
15601594
}
15611595

15621596
// if the metadata was not present in the response then we should not skip it
1563-
params.skipMeta = !(c.session.cfg.DisableSkipMetadata || qry.disableSkipMetadata) && info != nil && info.response.flags&flagNoMetaData == 0
1597+
params.skipMeta = !(c.session.cfg.DisableSkipMetadata || qry.disableSkipMetadata) && info != nil &&
1598+
info.response.flags&flagNoMetaData == 0
15641599

15651600
frame = &writeExecuteFrame{
15661601
preparedID: info.id,
@@ -1791,7 +1826,14 @@ func (c *Conn) executeBatch(ctx context.Context, batch *Batch) *Iter {
17911826
}
17921827

17931828
if len(values) != info.request.actualColCount {
1794-
return &Iter{err: fmt.Errorf("gocql: batch statement %d expected %d values send got %d", i, info.request.actualColCount, len(values))}
1829+
return &Iter{
1830+
err: fmt.Errorf(
1831+
"gocql: batch statement %d expected %d values send got %d",
1832+
i,
1833+
info.request.actualColCount,
1834+
len(values),
1835+
),
1836+
}
17951837
}
17961838

17971839
b.preparedID = info.id
@@ -1876,7 +1918,8 @@ func (c *Conn) querySystemPeers(ctx context.Context, version cassVersion) *Iter
18761918

18771919
err := iter.checkErrAndNotFound()
18781920
if err != nil {
1879-
if errFrame, ok := err.(errorFrame); ok && errFrame.code == ErrCodeInvalid { // system.peers_v2 not found, try system.peers
1921+
if errFrame, ok := err.(errorFrame); ok &&
1922+
errFrame.code == ErrCodeInvalid { // system.peers_v2 not found, try system.peers
18801923
c.mu.Lock()
18811924
c.isSchemaV2 = false
18821925
c.mu.Unlock()

control.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,12 @@ func (c *controlConn) connect(hosts []*HostInfo) error {
272272
for _, host := range hosts {
273273
conn, err = c.session.dial(c.session.ctx, host, &cfg, c)
274274
if err != nil {
275-
c.session.logger.Printf("gocql: unable to dial control conn %v:%v: %v\n", host.ConnectAddress(), host.Port(), err)
275+
c.session.logger.Printf(
276+
"gocql: unable to dial control conn %v:%v: %v\n",
277+
host.ConnectAddress(),
278+
host.Port(),
279+
err,
280+
)
276281
continue
277282
}
278283
err = c.setupConn(conn)
@@ -434,7 +439,12 @@ func (c *controlConn) attemptReconnectToAnyOfHosts(hosts []*HostInfo) (*Conn, er
434439
for _, host := range hosts {
435440
conn, err = c.session.connect(c.session.ctx, host, c)
436441
if err != nil {
437-
c.session.logger.Printf("gocql: unable to dial control conn %v:%v: %v\n", host.ConnectAddress(), host.Port(), err)
442+
c.session.logger.Printf(
443+
"gocql: unable to dial control conn %v:%v: %v\n",
444+
host.ConnectAddress(),
445+
host.Port(),
446+
err,
447+
)
438448
continue
439449
}
440450
err = c.setupConn(conn)

errors.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ type RequestErrUnavailable struct {
148148
}
149149

150150
func (e *RequestErrUnavailable) String() string {
151-
return fmt.Sprintf("[request_error_unavailable consistency=%s required=%d alive=%d]", e.Consistency, e.Required, e.Alive)
151+
return fmt.Sprintf(
152+
"[request_error_unavailable consistency=%s required=%d alive=%d]",
153+
e.Consistency,
154+
e.Required,
155+
e.Alive,
156+
)
152157
}
153158

154159
type ErrorMap map[string]uint16

0 commit comments

Comments
 (0)