Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Expose count of Scylla shards in HostInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-sucha committed Mar 2, 2023
1 parent cea7224 commit 25b2f1c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions host_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ type HostInfo struct {
schemaVersion string
tokens []string

scyllaShardAwarePort uint16
scyllaShardAwarePortTLS uint16
scyllaSupported scyllaSupported
}

func (h *HostInfo) Equal(host *HostInfo) bool {
Expand Down Expand Up @@ -442,24 +441,31 @@ func (h *HostInfo) String() string {
func (h *HostInfo) setScyllaSupported(s scyllaSupported) {
h.mu.Lock()
defer h.mu.Unlock()
h.scyllaShardAwarePort = s.shardAwarePort
h.scyllaShardAwarePortTLS = s.shardAwarePortSSL
h.scyllaSupported = s
}

// ScyllaShardAwarePort returns the shard aware port of this host.
// Returns zero if the shard aware port is not known.
func (h *HostInfo) ScyllaShardAwarePort() uint16 {
h.mu.RLock()
defer h.mu.RUnlock()
return h.scyllaShardAwarePort
return h.scyllaSupported.shardAwarePort
}

// ScyllaShardAwarePortTLS returns the TLS-enabled shard aware port of this host.
// Returns zero if the shard aware port is not known.
func (h *HostInfo) ScyllaShardAwarePortTLS() uint16 {
h.mu.RLock()
defer h.mu.RUnlock()
return h.scyllaShardAwarePortTLS
return h.scyllaSupported.shardAwarePortSSL
}

// ScyllaNrShards returns count of shards this host has.
// Returns zero if the shard count is not known.
func (h *HostInfo) ScyllaNrShards() int {
h.mu.RLock()
defer h.mu.RUnlock()
return h.scyllaSupported.nrShards
}

// Polls system.peers at a specific interval to find new hosts
Expand Down

0 comments on commit 25b2f1c

Please sign in to comment.