duel-redis 0.1.7 → 0.2.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
- data/CHANGELOG.md +23 -1
- data/README.md +6 -2
- data/lib/duel/redis/version.rb +1 -1
- data/lib/duel/redis.rb +45 -15
- data/sig/duel/redis.rbs +12 -3
- metadata +43 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d76de3bfdeda533e73e809a0ea72f4d1fbd57057de54235f1608d0cc139b2b0
|
|
4
|
+
data.tar.gz: 70518ca16c1ce0832d4f9d09538ce3d64fcec7ac8f36b0f007f945eb98e61051
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c5104bbaa0634bfa797df55cd01c817d3238cc73689f9f9a5eea7d9b4fdf98003ec0d648180728e01253311f2f5ad93aa1b359450f6b4b597aa161a77932a5d0
|
|
7
|
+
data.tar.gz: 2b1f9110e428afae36778b84ccabcb810feed7d8487d4bb2a0f0cb8b8aee108c63cc88688586ff71004d1a1f8c18968712aef8a7072a85903ba07d93c0b9238d
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-11-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `tcp: true` starts each worker's server on a port of 127.0.0.1's
|
|
15
|
+
alone, its URL `redis://127.0.0.1:PORT`, rather than a Unix socket:
|
|
16
|
+
the default on Windows, whose builds of Redis (Cygwin's, MSYS2's)
|
|
17
|
+
have Unix sockets of their own, which Windows's Ruby can't reach.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- On JRuby, a worker that found its server's Unix socket before the
|
|
22
|
+
server listened on it failed, rather than waiting: JRuby's refusal
|
|
23
|
+
there is an `IOError` (CRuby's an `Errno::ECONNREFUSED`), which the
|
|
24
|
+
plugin now takes for a server not ready yet, as duel-memcached does.
|
|
25
|
+
|
|
26
|
+
## [0.1.8] - 2026-11-12
|
|
27
|
+
|
|
28
|
+
No changes of its own: released in step with the other Duel gems.
|
|
29
|
+
|
|
10
30
|
## [0.1.7] - 2026-11-10
|
|
11
31
|
|
|
12
32
|
No changes of its own: released in step with the other Duel gems.
|
|
@@ -73,7 +93,9 @@ license. It needs Ruby 3.4 or later, Duel 0.1, and `redis-server`
|
|
|
73
93
|
read the next reply out of step.
|
|
74
94
|
|
|
75
95
|
|
|
76
|
-
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.
|
|
96
|
+
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.2.0...HEAD
|
|
97
|
+
[0.2.0]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.1.8...duel-redis-v0.2.0
|
|
98
|
+
[0.1.8]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.1.7...duel-redis-v0.1.8
|
|
77
99
|
[0.1.7]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.1.6...duel-redis-v0.1.7
|
|
78
100
|
[0.1.6]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.1.5...duel-redis-v0.1.6
|
|
79
101
|
[0.1.5]: https://github.com/sferik/duel-ruby/compare/duel-redis-v0.1.4...duel-redis-v0.1.5
|
data/README.md
CHANGED
|
@@ -37,7 +37,10 @@ Duel.configure { |c| c.use :redis }
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Each worker's server listens only on a Unix socket in the worker's own
|
|
40
|
-
directory
|
|
40
|
+
directory (or with `tcp: true`, on a port of 127.0.0.1's alone, as it
|
|
41
|
+
does by default on Windows, whose builds of Redis have Unix sockets
|
|
42
|
+
Windows's Ruby can't reach), with persistence off, and works in that
|
|
43
|
+
directory too
|
|
41
44
|
(`--dir`): if your `args:` turn persistence on, its snapshots and
|
|
42
45
|
append-only files go there, never in your project. Its URL is in
|
|
43
46
|
`DUEL_REDIS_URL`, and in `REDIS_URL` too, so a client that reads that
|
|
@@ -67,7 +70,8 @@ Options:
|
|
|
67
70
|
c.use :redis,
|
|
68
71
|
server: "valkey-server", # the program (default: DUEL_REDIS_SERVER, or redis-server)
|
|
69
72
|
args: ["--maxmemory", "64mb"], # more of its options
|
|
70
|
-
env: %w[CACHE_URL]
|
|
73
|
+
env: %w[CACHE_URL], # variables given its URL besides DUEL_REDIS_URL (default: REDIS_URL)
|
|
74
|
+
tcp: true # on a port of 127.0.0.1's, its URL redis://127.0.0.1:PORT (default: on Windows only)
|
|
71
75
|
```
|
|
72
76
|
|
|
73
77
|
The metrics come from the server's `INFO` (command statistics and
|
data/lib/duel/redis/version.rb
CHANGED
data/lib/duel/redis.rb
CHANGED
|
@@ -18,9 +18,12 @@ module Duel
|
|
|
18
18
|
#
|
|
19
19
|
# Benchmarks can call Duel::Redis.url and Duel::Redis.flush.
|
|
20
20
|
#
|
|
21
|
-
# The server listens only on a Unix socket in the worker's directory
|
|
22
|
-
#
|
|
23
|
-
#
|
|
21
|
+
# The server listens only on a Unix socket in the worker's directory
|
|
22
|
+
# (or with +tcp+, on a port of 127.0.0.1's alone: by default on Windows,
|
|
23
|
+
# whose builds of Redis, Cygwin's or MSYS2's, have Unix sockets of their
|
|
24
|
+
# own, which Windows's Ruby can't reach), and works there too (--dir):
|
|
25
|
+
# what its options make it write, a snapshot or an append-only file,
|
|
26
|
+
# goes there, never in the project.
|
|
24
27
|
# Its URL is in DUEL_REDIS_URL, and in REDIS_URL too (unless +env+
|
|
25
28
|
# names others), so a client that reads that finds it.
|
|
26
29
|
module Redis
|
|
@@ -35,12 +38,20 @@ module Duel
|
|
|
35
38
|
# (+server+ is the program, +args+ more of its options) and its
|
|
36
39
|
# metrics. Returns the plugin's own connection to it, a worker's
|
|
37
40
|
# (see Config#in_worker, and in tests, Duel::Testing.in_worker).
|
|
38
|
-
def self.configure(config, server: ENV.fetch("DUEL_REDIS_SERVER", "redis-server"), args: [], env: %w[REDIS_URL]
|
|
41
|
+
def self.configure(config, server: ENV.fetch("DUEL_REDIS_SERVER", "redis-server"), args: [], env: %w[REDIS_URL],
|
|
42
|
+
tcp: !Duel.unix_sockets?)
|
|
39
43
|
config.prepare(:worker) do |w|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
if tcp
|
|
45
|
+
# (Its port after OPTIONS' 0, which it takes the place of.)
|
|
46
|
+
port = w.port
|
|
47
|
+
w.spawn(*[server, "--dir", w.dir, *OPTIONS, "--port", port.to_s, "--bind", "127.0.0.1"] + args)
|
|
48
|
+
url = "redis://127.0.0.1:#{port}"
|
|
49
|
+
else
|
|
50
|
+
socket = w.path("redis.sock")
|
|
51
|
+
w.spawn(*[server, "--unixsocket", socket, "--dir", w.dir, *OPTIONS] + args)
|
|
52
|
+
url = "unix://#{socket}"
|
|
53
|
+
end
|
|
54
|
+
w.wait_until { Connection.ping(url) }
|
|
44
55
|
([URL] + env).to_h { |name| [name, url] }
|
|
45
56
|
end
|
|
46
57
|
connection = config.in_worker { |w| Connection.new(url).tap { |redis| w.at_stop { redis.close } } }
|
|
@@ -94,20 +105,39 @@ module Duel
|
|
|
94
105
|
# The first byte of a reply: its type, one of RESP2's.
|
|
95
106
|
STATUS, ERROR, INTEGER, BULK, ARRAY = "+-:$*".bytes
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
# A socket to the server at +url+: unix://PATH (or PATH alone), or
|
|
109
|
+
# redis://HOST:PORT, without TCP's delay before a small write (a
|
|
110
|
+
# command), whose reply would wait for it.
|
|
111
|
+
def self.socket(url)
|
|
112
|
+
address = address(url)
|
|
113
|
+
return UNIXSocket.new(url.delete_prefix("unix://")) unless address
|
|
114
|
+
|
|
115
|
+
host, port = address
|
|
116
|
+
# (RBS's setsockopt takes an Integer for the value, but Ruby's
|
|
117
|
+
# takes true too.)
|
|
118
|
+
TCPSocket.new(host, port).tap { |socket| socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true) } # steep:ignore ArgumentTypeMismatch
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# The host and port of a redis:// URL, or nil (a Unix socket's).
|
|
122
|
+
def self.address(url)
|
|
123
|
+
match = %r{\Aredis://([^:/]+):(\d+)\z}.match(url) or return
|
|
124
|
+
[match[1], Integer(match[2])]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def self.ping(url)
|
|
128
|
+
connection = socket(url)
|
|
99
129
|
begin
|
|
100
|
-
|
|
101
|
-
|
|
130
|
+
connection.write("PING\r\n")
|
|
131
|
+
connection.gets == "+PONG\r\n"
|
|
102
132
|
ensure
|
|
103
|
-
|
|
133
|
+
connection.close
|
|
104
134
|
end
|
|
105
|
-
rescue SystemCallError
|
|
135
|
+
rescue SystemCallError, IOError # (JRuby's refusal on a Unix socket is an IOError)
|
|
106
136
|
false
|
|
107
137
|
end
|
|
108
138
|
|
|
109
139
|
def initialize(url)
|
|
110
|
-
@socket =
|
|
140
|
+
@socket = Connection.socket(url)
|
|
111
141
|
end
|
|
112
142
|
|
|
113
143
|
# Sends a command; returns its reply, read whole (every type RESP2
|
data/sig/duel/redis.rbs
CHANGED
|
@@ -15,7 +15,9 @@ module Duel
|
|
|
15
15
|
# is the program, +args+ more of its options, +env+ the variables
|
|
16
16
|
# besides DUEL_REDIS_URL given its URL) and its metrics. Returns the
|
|
17
17
|
# plugin's own connection to it, a worker's.
|
|
18
|
-
|
|
18
|
+
# +tcp+: on a port of 127.0.0.1's, not a Unix socket (by default on
|
|
19
|
+
# Windows).
|
|
20
|
+
def self.configure: (Config config, ?server: String, ?args: Array[String], ?env: Array[String], ?tcp: bool) -> InWorker[Connection]
|
|
19
21
|
|
|
20
22
|
# What the worker's server has done so far, read over +connection+.
|
|
21
23
|
def self.stats: (Connection connection) -> Hash[String, Integer]
|
|
@@ -42,9 +44,16 @@ module Duel
|
|
|
42
44
|
BULK: Integer
|
|
43
45
|
ARRAY: Integer
|
|
44
46
|
|
|
45
|
-
@socket: UNIXSocket
|
|
47
|
+
@socket: UNIXSocket | TCPSocket
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
# A socket to the server at +url+ (unix://PATH, PATH, or
|
|
50
|
+
# redis://HOST:PORT).
|
|
51
|
+
def self.socket: (String url) -> (UNIXSocket | TCPSocket)
|
|
52
|
+
|
|
53
|
+
# The host and port of a redis:// URL, or nil.
|
|
54
|
+
def self.address: (String url) -> [String, Integer]?
|
|
55
|
+
|
|
56
|
+
def self.ping: (String url) -> bool
|
|
48
57
|
|
|
49
58
|
def initialize: (String url) -> void
|
|
50
59
|
|
metadata
CHANGED
|
@@ -1,65 +1,68 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duel-redis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Erik Berlin
|
|
7
|
+
- Erik Berlin
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: duel
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "0.2"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ~>
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "0.2"
|
|
28
|
+
description: "A Duel plugin: each worker gets a Redis server of its own, and every benchmark is judged on the Redis CPU time, commands and round trips it took too."
|
|
28
29
|
email:
|
|
29
|
-
- sferik@gmail.com
|
|
30
|
+
- sferik@gmail.com
|
|
30
31
|
executables: []
|
|
31
32
|
extensions: []
|
|
32
33
|
extra_rdoc_files: []
|
|
33
34
|
files:
|
|
34
|
-
- CHANGELOG.md
|
|
35
|
-
- LICENSE
|
|
36
|
-
- README.md
|
|
37
|
-
- lib/duel/redis.rb
|
|
38
|
-
- lib/duel/redis/version.rb
|
|
39
|
-
- sig/duel/redis.rbs
|
|
40
|
-
homepage: https://github.com/sferik/duel-ruby/tree/main/plugins/redis
|
|
35
|
+
- CHANGELOG.md
|
|
36
|
+
- LICENSE
|
|
37
|
+
- README.md
|
|
38
|
+
- lib/duel/redis.rb
|
|
39
|
+
- lib/duel/redis/version.rb
|
|
40
|
+
- sig/duel/redis.rbs
|
|
41
|
+
homepage: "https://github.com/sferik/duel-ruby/tree/main/plugins/redis"
|
|
41
42
|
licenses:
|
|
42
|
-
- MIT
|
|
43
|
+
- MIT
|
|
43
44
|
metadata:
|
|
44
|
-
source_code_uri: https://github.com/sferik/duel-ruby/tree/main/plugins/redis
|
|
45
|
-
changelog_uri: https://github.com/sferik/duel-ruby/blob/main/plugins/redis/CHANGELOG.md
|
|
46
|
-
bug_tracker_uri: https://github.com/sferik/duel-ruby/issues
|
|
47
|
-
rubygems_mfa_required:
|
|
45
|
+
source_code_uri: "https://github.com/sferik/duel-ruby/tree/main/plugins/redis"
|
|
46
|
+
changelog_uri: "https://github.com/sferik/duel-ruby/blob/main/plugins/redis/CHANGELOG.md"
|
|
47
|
+
bug_tracker_uri: "https://github.com/sferik/duel-ruby/issues"
|
|
48
|
+
rubygems_mfa_required: "true"
|
|
48
49
|
rdoc_options: []
|
|
49
50
|
require_paths:
|
|
50
|
-
- lib
|
|
51
|
+
- lib
|
|
51
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
53
|
requirements:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
-
|
|
55
|
+
- ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: "3.4"
|
|
56
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
59
|
requirements:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
-
|
|
61
|
+
- ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: "0"
|
|
61
64
|
requirements: []
|
|
62
|
-
rubygems_version: 4.0
|
|
65
|
+
rubygems_version: 4.1.0
|
|
63
66
|
specification_version: 4
|
|
64
|
-
summary: A Redis server for each Duel worker, and what it did for each benchmark
|
|
67
|
+
summary: "A Redis server for each Duel worker, and what it did for each benchmark"
|
|
65
68
|
test_files: []
|