-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue-1774: Method to retrieve info about client connections was added #1796
base: trunk
Are you sure you want to change the base?
Conversation
af5fe82
to
ccf3387
Compare
session.go
Outdated
// scans the results into a slice of `ClientConnection` structs. It handles nullable | ||
// fields and returns the list of connections or an error if the operation fails. | ||
func (s *Session) RetrieveClientConnections(connectionType connectionType) ([]*ClientConnection, error) { | ||
query := "SELECT address, port, connection_stage, driver_name, driver_version, hostname, keyspace_name, protocol_version, request_count, ssl_cipher_suite, ssl_enabled, ssl_protocol, username FROM system_views.clients WHERE connection_stage = ?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should follow the general pattern of code styling for similar methods that are used for querying some system/system_views tables. So you should define this query as a string const and use idents as well. You may find some examples in the Session.KeyspaceMetadata()
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fixed
session.go
Outdated
type ClientConnection struct { | ||
Address string `json:"address"` | ||
Port int `json:"port"` | ||
ConnectionStage string `json:"connection_stage"` | ||
DriverName string `json:"driver_name"` | ||
DriverVersion string `json:"driver_version"` | ||
Hostname string `json:"hostname"` | ||
KeyspaceName *string `json:"keyspace_name"` | ||
ProtocolVersion int `json:"protocol_version"` | ||
RequestCount int `json:"request_count"` | ||
SSLCipherSuite *string `json:"ssl_cipher_suite"` | ||
SSLEnabled bool `json:"ssl_enabled"` | ||
SSLProtocol *string `json:"ssl_protocol"` | ||
Username string `json:"username"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these json tags really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, removed
ccf3387
to
ae96fac
Compare
session.go
Outdated
|
||
iter := s.control.query(stmt, connectionType) | ||
if iter.NumRows() == 0 { | ||
return nil, ErrKeyspaceDoesNotExist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I missed this before. I think you should return an error related to connectionType, not keyspace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed, ty
ae96fac
to
ef8de83
Compare
fd7b28a
to
b2e98d5
Compare
b2e98d5
to
aa8e727
Compare
In this PR a new custom type
connectionType
was added to categorize different stages of client connections within a Cassandra cluster. Additionally, theClientConnection
struct was introduced to encapsulate detailed information about each connection, such as client address, connection stage, driver details, and SSL configuration. A new method,RetrieveClientConnections
, was implemented to retrieve client connections based on their connection stage from the system_views.clients table.