async-redis 0.13.0 → 0.14.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/index.yaml +2 -0
- data/lib/async/redis/cluster_client.rb +24 -25
- data/lib/async/redis/cluster_subscription.rb +2 -2
- data/lib/async/redis/endpoint.rb +1 -1
- data/lib/async/redis/range_map.rb +17 -15
- data/lib/async/redis/version.rb +1 -1
- data/license.md +2 -2
- data/readme.md +19 -3
- data.tar.gz.sig +0 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7df67fb815da0415518fcc011ff73ee1dce3fc6e5efa499062e53cbd02759330
|
|
4
|
+
data.tar.gz: 263cb0d0e8e6b773c52e6a238363199fa7349649999b5de0be6377c77a7f9af6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4a1c6346b810d497f5af9af1de602231db80dab9e1c500cf20ffd9528c326371ef1f2aad3038d033fcbdd7736765cea411cec0424394d3357f902f218d6c739
|
|
7
|
+
data.tar.gz: a6a3fae1da6a065f4c7c9eaf697b486b6065298ebb1d3ffe18e116d403e4273461e171846770b8ad246d0b0c6310ffc3c2a3ac71e034ecfd79aa9b0371b5d62b
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/index.yaml
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
---
|
|
4
4
|
description: A Redis client library.
|
|
5
5
|
metadata:
|
|
6
|
+
bug_tracker_uri: https://github.com/socketry/async-redis/issues
|
|
7
|
+
changelog_uri: https://github.com/socketry/async-redis/blob/main/releases.md
|
|
6
8
|
documentation_uri: https://socketry.github.io/async-redis/
|
|
7
9
|
source_code_uri: https://github.com/socketry/async-redis.git
|
|
8
10
|
files:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
4
|
# Copyright, 2024-2025, by Samuel Williams.
|
|
5
|
-
# Copyright, 2025, by Travis Bell.
|
|
5
|
+
# Copyright, 2025-2026, by Travis Bell.
|
|
6
6
|
|
|
7
7
|
require_relative "client"
|
|
8
8
|
require_relative "cluster_subscription"
|
|
@@ -110,37 +110,36 @@ module Async
|
|
|
110
110
|
protected
|
|
111
111
|
|
|
112
112
|
def reload_cluster!(endpoints = @endpoints)
|
|
113
|
-
@endpoints.each do |
|
|
114
|
-
client = Client.new(
|
|
113
|
+
@endpoints.each do |cluster_endpoint|
|
|
114
|
+
client = Client.new(cluster_endpoint, **@options)
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
client.call("CLUSTER", "SHARDS").each do |shard|
|
|
120
|
-
shard = shard.each_slice(2).to_h
|
|
121
|
-
|
|
122
|
-
slots = shard["slots"]
|
|
123
|
-
range = Range.new(*slots)
|
|
116
|
+
begin
|
|
117
|
+
shards = Async::Redis::RangeMap.new
|
|
124
118
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
endpoint = Endpoint.for(endpoint.scheme, node["endpoint"], port: node["port"])
|
|
119
|
+
client.call("CLUSTER", "SHARDS").each do |shard|
|
|
120
|
+
shard = shard.each_slice(2).to_h
|
|
128
121
|
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
nodes = shard["nodes"].map do |node|
|
|
123
|
+
node = node.each_slice(2).to_h
|
|
124
|
+
node_endpoint = Endpoint.for(cluster_endpoint.scheme, node["endpoint"], port: node["port"])
|
|
125
|
+
|
|
126
|
+
Node.new(node["id"], node_endpoint, node["role"].to_sym, node["health"].to_sym)
|
|
127
|
+
end
|
|
128
|
+
ranges = shard["slots"].each_slice(2).map do |first_slot, last_slot|
|
|
129
|
+
first_slot..last_slot
|
|
130
|
+
end
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
shards.add(ranges, nodes)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
shards
|
|
135
|
+
@shards = shards
|
|
136
|
+
|
|
137
|
+
return true
|
|
138
|
+
rescue Errno::ECONNREFUSED
|
|
139
|
+
next
|
|
140
|
+
ensure
|
|
141
|
+
client.close
|
|
136
142
|
end
|
|
137
|
-
|
|
138
|
-
@shards = shards
|
|
139
|
-
# @endpoints = @endpoints | endpoints
|
|
140
|
-
|
|
141
|
-
return true
|
|
142
|
-
rescue Errno::ECONNREFUSED
|
|
143
|
-
next
|
|
144
143
|
end
|
|
145
144
|
|
|
146
145
|
raise ReloadError, "Failed to reload cluster configuration."
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2025, by Samuel Williams.
|
|
4
|
+
# Copyright, 2025-2026, by Samuel Williams.
|
|
5
5
|
|
|
6
6
|
require "async/limited_queue"
|
|
7
7
|
require "async/barrier"
|
|
@@ -102,7 +102,7 @@ module Async
|
|
|
102
102
|
@channels -= channels_for_slot
|
|
103
103
|
|
|
104
104
|
# Check if this shard still has channels
|
|
105
|
-
remaining_channels_for_slot = @channels.select
|
|
105
|
+
remaining_channels_for_slot = @channels.select{|ch| @cluster_client.slot_for(ch) == slot}
|
|
106
106
|
|
|
107
107
|
# If no channels left for this shard, close and remove it
|
|
108
108
|
if remaining_channels_for_slot.empty?
|
data/lib/async/redis/endpoint.rb
CHANGED
|
@@ -80,7 +80,7 @@ module Async
|
|
|
80
80
|
scheme ||= default_scheme
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
scheme ||= options
|
|
83
|
+
scheme ||= options[:ssl_context] ? "rediss" : "redis"
|
|
84
84
|
|
|
85
85
|
uri_klass = SCHEMES.fetch(scheme.downcase) do
|
|
86
86
|
raise ArgumentError, "Unsupported scheme: #{scheme.inspect}"
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
4
|
# Copyright, 2025, by Samuel Williams.
|
|
5
|
+
# Copyright, 2026, by Travis Bell.
|
|
5
6
|
|
|
6
7
|
module Async
|
|
7
8
|
module Redis
|
|
8
|
-
# A map that
|
|
9
|
+
# A map that associates one or more ranges with a value for efficient lookup.
|
|
9
10
|
class RangeMap
|
|
10
11
|
# Initialize a new RangeMap.
|
|
11
12
|
def initialize
|
|
12
|
-
@
|
|
13
|
+
@entries = []
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
# Add a
|
|
16
|
-
# @parameter
|
|
17
|
-
# @parameter value [Object] The value to associate with the
|
|
16
|
+
# Add one or more ranges associated with a value to the map.
|
|
17
|
+
# @parameter ranges [Range | Array(Range)] The ranges to map.
|
|
18
|
+
# @parameter value [Object] The value to associate with the ranges.
|
|
18
19
|
# @returns [Object] The added value.
|
|
19
|
-
def add(
|
|
20
|
-
|
|
20
|
+
def add(ranges, value)
|
|
21
|
+
ranges = [ranges] if ranges.is_a?(Range)
|
|
22
|
+
@entries << [ranges, value]
|
|
21
23
|
return value
|
|
22
24
|
end
|
|
23
25
|
|
|
@@ -26,8 +28,8 @@ module Async
|
|
|
26
28
|
# @yields {...} Block called if no range contains the key.
|
|
27
29
|
# @returns [Object] The value if found, result of block if given, or nil.
|
|
28
30
|
def find(key)
|
|
29
|
-
@
|
|
30
|
-
return value if range.include?(key)
|
|
31
|
+
@entries.each do |ranges, value|
|
|
32
|
+
return value if ranges.any?{|range| range.include?(key)}
|
|
31
33
|
end
|
|
32
34
|
if block_given?
|
|
33
35
|
return yield
|
|
@@ -35,11 +37,11 @@ module Async
|
|
|
35
37
|
return nil
|
|
36
38
|
end
|
|
37
39
|
|
|
38
|
-
# Iterate over
|
|
40
|
+
# Iterate over each mapped value.
|
|
39
41
|
# @yields {|value| ...} Block called for each value.
|
|
40
|
-
# @parameter value [Object] The value
|
|
42
|
+
# @parameter value [Object] The value associated with one or more ranges.
|
|
41
43
|
def each
|
|
42
|
-
@
|
|
44
|
+
@entries.each do |_, value|
|
|
43
45
|
yield value
|
|
44
46
|
end
|
|
45
47
|
end
|
|
@@ -47,14 +49,14 @@ module Async
|
|
|
47
49
|
# Get a random value from the map.
|
|
48
50
|
# @returns [Object] A randomly selected value, or nil if map is empty.
|
|
49
51
|
def sample
|
|
50
|
-
return nil if @
|
|
51
|
-
|
|
52
|
+
return nil if @entries.empty?
|
|
53
|
+
_, value = @entries.sample
|
|
52
54
|
return value
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
# Clear all ranges from the map.
|
|
56
58
|
def clear
|
|
57
|
-
@
|
|
59
|
+
@entries.clear
|
|
58
60
|
end
|
|
59
61
|
end
|
|
60
62
|
end
|
data/lib/async/redis/version.rb
CHANGED
data/license.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright, 2018-
|
|
3
|
+
Copyright, 2018-2026, by Samuel Williams.
|
|
4
4
|
Copyright, 2018, by Huba Nagy.
|
|
5
5
|
Copyright, 2019-2020, by David Ortiz.
|
|
6
6
|
Copyright, 2019, by Pierre Montelle.
|
|
@@ -13,7 +13,7 @@ Copyright, 2021, by Troex Nevelin.
|
|
|
13
13
|
Copyright, 2022, by Tim Willard.
|
|
14
14
|
Copyright, 2022, by Gleb Sinyavskiy.
|
|
15
15
|
Copyright, 2024-2025, by Joan Lledó.
|
|
16
|
-
Copyright, 2025, by Travis Bell.
|
|
16
|
+
Copyright, 2025-2026, by Travis Bell.
|
|
17
17
|
|
|
18
18
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
19
19
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
|
@@ -60,11 +60,27 @@ Please see the [project releases](https://socketry.github.io/async-redis/release
|
|
|
60
60
|
|
|
61
61
|
We welcome contributions to this project.
|
|
62
62
|
|
|
63
|
-
1. Fork
|
|
63
|
+
1. Fork the repository.
|
|
64
64
|
2. Create your feature branch (`git checkout -b my-new-feature`).
|
|
65
|
-
3. Commit your changes (`git commit -am 'Add some feature'`).
|
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature.'`).
|
|
66
66
|
4. Push to the branch (`git push origin my-new-feature`).
|
|
67
|
-
5. Create new
|
|
67
|
+
5. Create a new pull request.
|
|
68
|
+
|
|
69
|
+
### Running Tests
|
|
70
|
+
|
|
71
|
+
To run the test suite:
|
|
72
|
+
|
|
73
|
+
``` shell
|
|
74
|
+
bundle exec sus
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Making Releases
|
|
78
|
+
|
|
79
|
+
To make a new release:
|
|
80
|
+
|
|
81
|
+
``` shell
|
|
82
|
+
bundle exec bake gem:release:patch # or minor or major
|
|
83
|
+
```
|
|
68
84
|
|
|
69
85
|
### Developer Certificate of Origin
|
|
70
86
|
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: async-redis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
8
|
- Huba Nagy
|
|
9
9
|
- David Ortiz
|
|
10
10
|
- Joan Lledó
|
|
11
|
+
- Travis Bell
|
|
11
12
|
- Gleb Sinyavskiy
|
|
12
13
|
- Mikael Henriksson
|
|
13
|
-
- Travis Bell
|
|
14
14
|
- Troex Nevelin
|
|
15
15
|
- Alex Matchneer
|
|
16
16
|
- Jeremy Jung
|
|
@@ -156,6 +156,8 @@ homepage: https://github.com/socketry/async-redis
|
|
|
156
156
|
licenses:
|
|
157
157
|
- MIT
|
|
158
158
|
metadata:
|
|
159
|
+
bug_tracker_uri: https://github.com/socketry/async-redis/issues
|
|
160
|
+
changelog_uri: https://github.com/socketry/async-redis/blob/main/releases.md
|
|
159
161
|
documentation_uri: https://socketry.github.io/async-redis/
|
|
160
162
|
source_code_uri: https://github.com/socketry/async-redis.git
|
|
161
163
|
rdoc_options: []
|
|
@@ -165,14 +167,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
165
167
|
requirements:
|
|
166
168
|
- - ">="
|
|
167
169
|
- !ruby/object:Gem::Version
|
|
168
|
-
version: '3.
|
|
170
|
+
version: '3.3'
|
|
169
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
172
|
requirements:
|
|
171
173
|
- - ">="
|
|
172
174
|
- !ruby/object:Gem::Version
|
|
173
175
|
version: '0'
|
|
174
176
|
requirements: []
|
|
175
|
-
rubygems_version:
|
|
177
|
+
rubygems_version: 4.0.10
|
|
176
178
|
specification_version: 4
|
|
177
179
|
summary: A Redis client library.
|
|
178
180
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|