Skip to content

Commit c6fb2b2

Browse files
committed
enable: fieldalignment
1 parent 943a049 commit c6fb2b2

23 files changed

+433
-795
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ linters:
123123
enable-all: true
124124
disable:
125125
- shadow
126-
- fieldalignment # TODO: too many complaints, to be enabled in a separate PR
127126
inamedparam:
128127
skip-single-param: true
129128

cluster.go

Lines changed: 47 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -51,231 +51,56 @@ func (p PoolConfig) buildPool(session *Session) *policyConnPool {
5151
// behavior to fit the most common use cases. Applications that require a
5252
// different setup must implement their own cluster.
5353
type ClusterConfig struct {
54-
// addresses for the initial connections. It is recommended to use the value set in
55-
// the Cassandra config for broadcast_address or listen_address, an IP address not
56-
// a domain name. This is because events from Cassandra will use the configured IP
57-
// address, which is used to index connected hosts. If the domain name specified
58-
// resolves to more than 1 IP address then the driver may connect multiple times to
59-
// the same host, and will not mark the node being down or up from events.
60-
Hosts []string
61-
62-
// CQL version (default: 3.0.0)
63-
CQLVersion string
64-
65-
// ProtoVersion sets the version of the native protocol to use, this will
66-
// enable features in the driver for specific protocol versions, generally this
67-
// should be set to a known version (2,3,4) for the cluster being connected to.
68-
//
69-
// If it is 0 or unset (the default) then the driver will attempt to discover the
70-
// highest supported protocol for the cluster. In clusters with nodes of different
71-
// versions the protocol selected is not defined (ie, it can be any of the supported in the cluster)
72-
ProtoVersion int
73-
74-
// Timeout limits the time spent on the client side while executing a query.
75-
// Specifically, query or batch execution will return an error if the client does not receive a response
76-
// from the server within the Timeout period.
77-
// Timeout is also used to configure the read timeout on the underlying network connection.
78-
// Client Timeout should always be higher than the request timeouts configured on the server,
79-
// so that retries don't overload the server.
80-
// Timeout has a default value of 11 seconds, which is higher than default server timeout for most query types.
81-
// Timeout is not applied to requests during initial connection setup, see ConnectTimeout.
82-
Timeout time.Duration
83-
84-
// ConnectTimeout limits the time spent during connection setup.
85-
// During initial connection setup, internal queries, AUTH requests will return an error if the client
86-
// does not receive a response within the ConnectTimeout period.
87-
// ConnectTimeout is applied to the connection setup queries independently.
88-
// ConnectTimeout also limits the duration of dialing a new TCP connection
89-
// in case there is no Dialer nor HostDialer configured.
90-
// ConnectTimeout has a default value of 11 seconds.
91-
ConnectTimeout time.Duration
92-
93-
// WriteTimeout limits the time the driver waits to write a request to a network connection.
94-
// WriteTimeout should be lower than or equal to Timeout.
95-
// WriteTimeout defaults to the value of Timeout.
96-
WriteTimeout time.Duration
97-
98-
// Port used when dialing.
99-
// Default: 9042
100-
Port int
101-
102-
// Initial keyspace. Optional.
103-
Keyspace string
104-
105-
// The size of the connection pool for each host.
106-
// The pool filling runs in separate gourutine during the session initialization phase.
107-
// gocql will always try to get 1 connection on each host pool
108-
// during session initialization AND it will attempt
109-
// to fill each pool afterward asynchronously if NumConns > 1.
110-
// Notice: There is no guarantee that pool filling will be finished in the initialization phase.
111-
// Also, it describes a maximum number of connections at the same time.
112-
// Default: 2
113-
NumConns int
114-
115-
// Default consistency level.
116-
// Default: Quorum
117-
Consistency Consistency
118-
119-
// Compression algorithm.
120-
// Default: nil
121-
Compressor Compressor
122-
123-
// Default: nil
124-
Authenticator Authenticator
125-
126-
// An Authenticator factory. Can be used to create alternative authenticators.
127-
// Default: nil
128-
AuthProvider func(h *HostInfo) (Authenticator, error)
129-
130-
// Default retry policy to use for queries.
131-
// Default: no retries.
132-
RetryPolicy RetryPolicy
133-
134-
// ConvictionPolicy decides whether to mark host as down based on the error and host info.
135-
// Default: SimpleConvictionPolicy
136-
ConvictionPolicy ConvictionPolicy
137-
138-
// Default reconnection policy to use for reconnecting before trying to mark host as down.
139-
ReconnectionPolicy ReconnectionPolicy
140-
141-
// The keepalive period to use, enabled if > 0 (default: 0)
142-
// SocketKeepalive is used to set up the default dialer and is ignored if Dialer or HostDialer is provided.
143-
SocketKeepalive time.Duration
144-
145-
// Maximum cache size for prepared statements globally for gocql.
146-
// Default: 1000
147-
MaxPreparedStmts int
148-
149-
// Maximum cache size for query info about statements for each session.
150-
// Default: 1000
151-
MaxRoutingKeyInfo int
152-
153-
// Default page size to use for created sessions.
154-
// Default: 5000
155-
PageSize int
156-
157-
// Consistency for the serial part of queries, values can be either SERIAL or LOCAL_SERIAL.
158-
// Default: unset
159-
SerialConsistency Consistency
160-
161-
// SslOpts configures TLS use when HostDialer is not set.
162-
// SslOpts is ignored if HostDialer is set.
163-
SslOpts *SslOptions
164-
165-
// Sends a client side timestamp for all requests which overrides the timestamp at which it arrives at the server.
166-
// Default: true, only enabled for protocol 3 and above.
167-
DefaultTimestamp bool
168-
169-
// PoolConfig configures the underlying connection pool, allowing the
170-
// configuration of host selection and connection selection policies.
171-
PoolConfig PoolConfig
172-
173-
// If not zero, gocql attempt to reconnect known DOWN nodes in every ReconnectInterval.
174-
ReconnectInterval time.Duration
175-
176-
// The maximum amount of time to wait for schema agreement in a cluster after
177-
// receiving a schema change frame. (default: 60s)
54+
BatchObserver BatchObserver
55+
ConnectObserver ConnectObserver
56+
Tracer Tracer
57+
Logger StdLogger
58+
HostDialer HostDialer
59+
Dialer Dialer
60+
StreamObserver StreamObserver
61+
FrameHeaderObserver FrameHeaderObserver
62+
QueryObserver QueryObserver
63+
AddressTranslator AddressTranslator
64+
Compressor Compressor
65+
Authenticator Authenticator
66+
HostFilter HostFilter
67+
RetryPolicy RetryPolicy
68+
ConvictionPolicy ConvictionPolicy
69+
PoolConfig PoolConfig
70+
ReconnectionPolicy ReconnectionPolicy
71+
AuthProvider func(h *HostInfo) (Authenticator, error)
72+
SslOpts *SslOptions
73+
CQLVersion string
74+
Keyspace string
75+
Hosts []string
76+
ReconnectInterval time.Duration
77+
WriteCoalesceWaitTime time.Duration
78+
NumConns int
17879
MaxWaitSchemaAgreement time.Duration
179-
180-
// HostFilter will filter all incoming events for host, any which don't pass
181-
// the filter will be ignored. If set will take precedence over any options set
182-
// via Discovery
183-
HostFilter HostFilter
184-
185-
// AddressTranslator will translate addresses found on peer discovery and/or
186-
// node change events.
187-
AddressTranslator AddressTranslator
188-
189-
// If IgnorePeerAddr is true and the address in system.peers does not match
190-
// the supplied host by either initial hosts or discovered via events then the
191-
// host will be replaced with the supplied address.
192-
//
193-
// For example if an event comes in with host=10.0.0.1 but when looking up that
194-
// address in system.local or system.peers returns 127.0.0.1, the peer will be
195-
// set to 10.0.0.1 which is what will be used to connect to.
196-
IgnorePeerAddr bool
197-
198-
// If DisableInitialHostLookup then the driver will not attempt to get host info
199-
// from the system.peers table, this will mean that the driver will connect to
200-
// hosts supplied and will not attempt to lookup the hosts information, this will
201-
// mean that data_center, rack and token information will not be available and as
202-
// such host filtering and token aware query routing will not be available.
203-
DisableInitialHostLookup bool
204-
205-
// Configure events the driver will register for
206-
Events struct {
207-
// disable registering for status events (node up/down)
80+
NextPagePrefetch float64
81+
ProtoVersion int
82+
Timeout time.Duration
83+
ConnectTimeout time.Duration
84+
MaxPreparedStmts int
85+
PageSize int
86+
WriteTimeout time.Duration
87+
MaxRoutingKeyInfo int
88+
SocketKeepalive time.Duration
89+
Port int
90+
Consistency Consistency
91+
SerialConsistency Consistency
92+
Events struct {
20893
DisableNodeStatusEvents bool
209-
// disable registering for topology events (node added/removed/moved)
210-
DisableTopologyEvents bool
211-
// disable registering for schema events (keyspace/table/function removed/created/updated)
212-
DisableSchemaEvents bool
94+
DisableTopologyEvents bool
95+
DisableSchemaEvents bool
21396
}
214-
215-
// DisableSkipMetadata will override the internal result metadata cache so that the driver does not
216-
// send skip_metadata for queries, this means that the result will always contain
217-
// the metadata to parse the rows and will not reuse the metadata from the prepared
218-
// statement.
219-
//
220-
// See https://issues.apache.org/jira/browse/CASSANDRA-10786
221-
DisableSkipMetadata bool
222-
223-
// QueryObserver will set the provided query observer on all queries created from this session.
224-
// Use it to collect metrics / stats from queries by providing an implementation of QueryObserver.
225-
QueryObserver QueryObserver
226-
227-
// BatchObserver will set the provided batch observer on all queries created from this session.
228-
// Use it to collect metrics / stats from batch queries by providing an implementation of BatchObserver.
229-
BatchObserver BatchObserver
230-
231-
// ConnectObserver will set the provided connect observer on all queries
232-
// created from this session.
233-
ConnectObserver ConnectObserver
234-
235-
// FrameHeaderObserver will set the provided frame header observer on all frames' headers created from this session.
236-
// Use it to collect metrics / stats from frames by providing an implementation of FrameHeaderObserver.
237-
FrameHeaderObserver FrameHeaderObserver
238-
239-
// StreamObserver will be notified of stream state changes.
240-
// This can be used to track in-flight protocol requests and responses.
241-
StreamObserver StreamObserver
242-
243-
// Default idempotence for queries
244-
DefaultIdempotence bool
245-
246-
// The time to wait for frames before flushing the frames connection to Cassandra.
247-
// Can help reduce syscall overhead by making less calls to write. Set to 0 to
248-
// disable.
249-
//
250-
// (default: 200 microseconds)
251-
WriteCoalesceWaitTime time.Duration
252-
253-
// Dialer will be used to establish all connections created for this Cluster.
254-
// If not provided, a default dialer configured with ConnectTimeout will be used.
255-
// Dialer is ignored if HostDialer is provided.
256-
Dialer Dialer
257-
258-
// HostDialer will be used to establish all connections for this Cluster.
259-
// If not provided, Dialer will be used instead.
260-
HostDialer HostDialer
261-
262-
// Logger for this ClusterConfig.
263-
// If not specified, defaults to the gocql.defaultLogger.
264-
Logger StdLogger
265-
266-
// Tracer will be used for all queries. Alternatively it can be set of on a
267-
// per query basis.
268-
// default: nil
269-
Tracer Tracer
270-
271-
// NextPagePrefetch sets the default threshold for pre-fetching new pages. If
272-
// there are only p*pageSize rows remaining, the next page will be requested
273-
// automatically. This value can also be changed on a per-query basis.
274-
// default: 0.25.
275-
NextPagePrefetch float64
276-
277-
// internal config for testing
278-
disableControlConn bool
97+
DisableSkipMetadata bool
98+
DefaultIdempotence bool
99+
DefaultTimestamp bool
100+
DisableInitialHostLookup bool
101+
IgnorePeerAddr bool
102+
disableControlConn bool // disable registering for status events (node up/down)
103+
// disable registering for schema events (keyspace/table/function removed/created/updated)
279104
}
280105

281106
type Dialer interface {

0 commit comments

Comments
 (0)