redis-cluster-client 0.16.3 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80b5e1d6525a06ecf8747239269b110528bf9efc99ff3424108033c85cdc011a
|
|
4
|
+
data.tar.gz: 35b5aba54bc61e3731509c7ba3959289ddcfb30e40193f365fc26f62f4c7e60d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab546dc6dc75d1ec1733c5cd5f29a451881d71db8c21e587be92ab77c2f12f602100468626b742a1d87caa98aa27699906f9aefd7d9cff02512c3be1e355bdd4
|
|
7
|
+
data.tar.gz: 741326d16416834940e08c7084019080188d3e6b252c6dafdf3037bb9a40e2f9aafc0dc771fce7ac4edbb50af6d630067fb3646f4e7f1016ab72d7ceafb04940
|
|
@@ -412,13 +412,13 @@ class RedisClient
|
|
|
412
412
|
primary_id = nodes.find { |n| n.fetch('role') == 'master' }.fetch('id')
|
|
413
413
|
|
|
414
414
|
nodes.each do |node|
|
|
415
|
-
|
|
416
|
-
next if node.fetch('health') != 'online' ||
|
|
415
|
+
host = pick_shard_host(node)
|
|
416
|
+
next if node.fetch('health') != 'online' || host.nil? || host.empty? || host == '?'
|
|
417
417
|
|
|
418
418
|
role = node.fetch('role')
|
|
419
419
|
acc << ::RedisClient::Cluster::Node::Info.new(
|
|
420
420
|
id: node.fetch('id'),
|
|
421
|
-
node_key: NodeKey.build_from_host_port(
|
|
421
|
+
node_key: NodeKey.build_from_host_port(host, node['port'] || node['tls-port']),
|
|
422
422
|
role: role == 'master' ? role : 'slave',
|
|
423
423
|
primary_id: role == 'master' ? EMPTY_STRING : primary_id,
|
|
424
424
|
slots: role == 'master' ? shard.fetch('slots').each_slice(2).to_a.freeze : EMPTY_ARRAY
|
|
@@ -427,6 +427,25 @@ class RedisClient
|
|
|
427
427
|
end
|
|
428
428
|
end
|
|
429
429
|
|
|
430
|
+
# Pick the host for a CLUSTER SHARDS node entry.
|
|
431
|
+
#
|
|
432
|
+
# `endpoint` is the server-selected preferred endpoint (driven by the
|
|
433
|
+
# `cluster-preferred-endpoint-type` config), so prefer it when present and
|
|
434
|
+
# usable. Some managed services (e.g. AWS ElastiCache Serverless) report
|
|
435
|
+
# `127.0.0.1` in `ip` while exposing the reachable address only via
|
|
436
|
+
# `endpoint` / `hostname`; falling through to `ip` in that case would build
|
|
437
|
+
# an unreachable topology. This mirrors the precedence `parse_node_key`
|
|
438
|
+
# uses for CLUSTER NODES output (see #207).
|
|
439
|
+
def pick_shard_host(node)
|
|
440
|
+
endpoint = node['endpoint']
|
|
441
|
+
return endpoint if endpoint && !endpoint.empty? && endpoint != '?'
|
|
442
|
+
|
|
443
|
+
hostname = node['hostname']
|
|
444
|
+
return hostname if hostname && !hostname.empty?
|
|
445
|
+
|
|
446
|
+
node['ip']
|
|
447
|
+
end
|
|
448
|
+
|
|
430
449
|
# As redirection node_key is dependent on `cluster-preferred-endpoint-type` config,
|
|
431
450
|
# node_key should use hostname if present in CLUSTER NODES output.
|
|
432
451
|
#
|