duel-mysql 0.1.8 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2839b8ed6c5fd6afa8e7d5d7fa84c99ffd34b169bc7a5cd28706a5dc153fab37
4
- data.tar.gz: 1b95ad9e59ccb9d8450195c1955c30661943b7cc364c53b5f5e598039ed866ae
3
+ metadata.gz: 3c60008fbba47694875466924f67976f827b0ef49afb6b96c92ca2896382dc62
4
+ data.tar.gz: 54bf9e196f728fd2865ce153591ee8adbf95aa4d0f7a159adcb74a0c8aeada11
5
5
  SHA512:
6
- metadata.gz: 78fc25d07516255f740ef0c58f2ff934fc54178e1582dbd9ec3ec2c1056753eef582567c49debb5abe37a967b6a7daf2beb162852fefd8661632f7773e912eb5
7
- data.tar.gz: 1a2a20de6194aec43062ec66aea1f8302b2c9c36db6ef198572a924d1c71f74096ee59c7d6b972c9c2ba21844a00252bc543a15e14117dc710638a5ab77dc055
6
+ metadata.gz: a30b65dae62d540c5c594dc41f1f730001351568a69c8f7496926060a6b97548b35fe12207722474b9e6237eeb3b1890ad28f83a5869a4875656fb7fcf1761b5
7
+ data.tar.gz: 8f7d1b46f6c71967bac9aa9dbaba01857da209b252022505e4f243cf123b298db435c3fbba32eeaa76243c7b3472b35f04d1f019dbc7bd1e8886807795cbc0de
data/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ 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 `mysql2://root@127.0.0.1:PORT/duel`, with no
16
+ `DUEL_MYSQL_SOCKET`. It's the default on Windows, whose MySQL has no
17
+ Unix socket.
18
+
19
+ ### Changed
20
+
21
+ - The plugin reads the server's statistics with a client of its own,
22
+ in MySQL's protocol, so it no longer needs the trilogy gem (or a
23
+ build of it for Windows). `Duel::MySQL.execute` and `.reset`
24
+ return a `Duel::MySQL::Result`, and a statement that fails raises
25
+ `Duel::MySQL::Error`. Reading a server's statistics allocates a few
26
+ more objects than it did with Trilogy, which parsed MySQL's replies in
27
+ C (58 a reading, against 53.5, in the plugin's own benchmark), and
28
+ takes the same time. It gives up on a server that hasn't answered in
29
+ 10 seconds, raising `IOError`, where it would wait forever.
30
+
31
+ ### Fixed
32
+
33
+ - A `server:` path with a backslash in it (Windows's,
34
+ `C:\mysql\bin\mysqld`) is run as it is: the plugin looked for a
35
+ program by that name on the `PATH`.
36
+ - On Windows, `mysqld.exe` on the `PATH` (or a `server:` path without
37
+ its `.exe`) is found: the plugin looked for a file named `mysqld`.
38
+
10
39
  ## [0.1.8] - 2026-11-12
11
40
 
12
41
  ### Added
@@ -110,7 +139,8 @@ or later (not MariaDB).
110
139
  CI.
111
140
  - RBS signatures in sig/, checked with Steep.
112
141
 
113
- [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-mysql-v0.1.8...HEAD
142
+ [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-mysql-v0.2.0...HEAD
143
+ [0.2.0]: https://github.com/sferik/duel-ruby/compare/duel-mysql-v0.1.8...duel-mysql-v0.2.0
114
144
  [0.1.8]: https://github.com/sferik/duel-ruby/compare/duel-mysql-v0.1.7...duel-mysql-v0.1.8
115
145
  [0.1.7]: https://github.com/sferik/duel-ruby/compare/duel-mysql-v0.1.6...duel-mysql-v0.1.7
116
146
  [0.1.6]: https://github.com/sferik/duel-ruby/compare/duel-mysql-v0.1.5...duel-mysql-v0.1.6
data/README.md CHANGED
@@ -48,9 +48,8 @@ end
48
48
 
49
49
  > [!NOTE]
50
50
  > It needs MySQL 8.0.30 or later (not MariaDB: its `performance_schema`
51
- > differs) and the [trilogy](https://github.com/trilogy-libraries/trilogy)
52
- > gem, so CRuby (TruffleRuby 40.0 fails inside trilogy once benchmarks
53
- > run). Your code can use any client: trilogy is only the plugin's own.
51
+ > differs). The plugin reads the server's statistics with a small client
52
+ > of its own, so it needs no client gem, and your code can use any.
54
53
 
55
54
  ## Usage
56
55
 
@@ -62,16 +61,18 @@ Duel.configure { |c| c.use :mysql }
62
61
  `c.use` requires the plugin, so `.duel.rb` doesn't need to.
63
62
 
64
63
  Each worker's server listens only on a Unix socket in the worker's own
65
- directory (no `my.cnf` is read), with no binary log, little memory,
64
+ directory (or with `tcp: true`, on a port of 127.0.0.1's alone, as it
65
+ does by default on Windows, whose MySQL has no Unix socket). No
66
+ `my.cnf` is read, and it runs with no binary log, little memory,
66
67
  nothing written to disk that needn't be, and InnoDB's statistics left as
67
68
  they are (recalculated on their own, they'd change a query's plan while
68
69
  it's measured: `ANALYZE TABLE` in a setup if you need them). Its URL is
69
70
  in `DUEL_MYSQL_URL`, and in `DATABASE_URL` too, so a client that reads
70
71
  that finds it and nothing reaches another database. The socket's path
71
- is in `DUEL_MYSQL_SOCKET`. Benchmarks can call `Duel::MySQL.url`,
72
+ is in `DUEL_MYSQL_SOCKET` (with `tcp`, there's none). Benchmarks can call `Duel::MySQL.url`,
72
73
  `Duel::MySQL.socket`, `Duel::MySQL.execute` and `Duel::MySQL.reset`
73
- (each of these two opens a connection of its own, from the worker's
74
- `DUEL_MYSQL_SOCKET`, and closes it).
74
+ (each of these two opens a connection of its own to the worker's
75
+ server, and closes it).
75
76
 
76
77
  > [!IMPORTANT]
77
78
  > `execute` and `reset` are for setting up: call them in a `setup` hook,
@@ -98,7 +99,8 @@ c.use :mysql,
98
99
  args: ["--sort-buffer-size=4M"], # more of its options
99
100
  setup: File.read("db/structure.sql"), # SQL each worker's database runs first
100
101
  env: %w[DATABASE_URL PRIMARY_URL], # variables given its URL besides DUEL_MYSQL_URL
101
- scheme: "trilogy" # the URL's (Rails takes it for the adapter, mysql2 by default)
102
+ scheme: "trilogy", # the URL's (Rails takes it for the adapter, mysql2 by default)
103
+ tcp: true # on a port of 127.0.0.1's, its URL mysql2://root@127.0.0.1:PORT/duel (default: on Windows only)
102
104
  ```
103
105
 
104
106
  > [!WARNING]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Duel
4
4
  module MySQL
5
- VERSION = "0.1.8"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/duel/mysql.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require "duel"
4
4
  require "digest"
5
5
  require "fileutils"
6
+ require "rbconfig"
7
+ require "socket"
6
8
  require_relative "mysql/version"
7
9
 
8
10
  module Duel
@@ -25,9 +27,12 @@ module Duel
25
27
  # .reset in setup (or untimed blocks): while a benchmark is measured,
26
28
  # they fail.
27
29
  #
28
- # The server listens only on a Unix socket in the worker's directory;
29
- # its URL is in DUEL_MYSQL_URL, and in DATABASE_URL too (unless +env+
30
- # names others), and the socket's path in DUEL_MYSQL_SOCKET.
30
+ # The server listens only on a Unix socket in the worker's directory
31
+ # (or with +tcp+, on a port of 127.0.0.1's alone: by default on Windows,
32
+ # whose MySQL has none); its URL is in DUEL_MYSQL_URL, and in
33
+ # DATABASE_URL too (unless +env+ names others), and the socket's path
34
+ # in DUEL_MYSQL_SOCKET (with +tcp+, none). The plugin's connections are
35
+ # a client of its own (see Connection): no gem's.
31
36
  module MySQL
32
37
  Duel.plugin(:mysql, self)
33
38
 
@@ -37,13 +42,14 @@ module Duel
37
42
  USER = "root"
38
43
 
39
44
  # The server's options (after --no-defaults: no my.cnf of the
40
- # machine's): no network, nothing to disk that needn't be, little
45
+ # machine's): errors to its output (its log: on Windows, they'd go to a
46
+ # file of their own), nothing to disk that needn't be, little
41
47
  # memory, no Linux AIO contexts (there are only so many, for every
42
48
  # server on the machine), and nothing running on its own
43
49
  # (recalculating a table's statistics would change its plans while
44
50
  # they're measured).
45
51
  OPTIONS = %w[
46
- --skip-networking --mysqlx=OFF --skip-log-bin
52
+ --console --mysqlx=OFF --skip-log-bin
47
53
  --innodb-buffer-pool-size=32M --innodb-redo-log-capacity=8M --innodb-doublewrite=OFF --innodb-use-native-aio=OFF
48
54
  --innodb-flush-log-at-trx-commit=0 --innodb-stats-auto-recalc=OFF --event-scheduler=OFF --performance-schema=ON
49
55
  ].freeze
@@ -67,40 +73,46 @@ module Duel
67
73
  # to it, a worker's (see Config#in_worker, and in tests,
68
74
  # Duel::Testing.in_worker).
69
75
  def self.configure(config, server: ENV.fetch("DUEL_MYSQL_SERVER", "mysqld"), args: [], setup: nil, env: %w[DATABASE_URL],
70
- scheme: "mysql2")
76
+ scheme: "mysql2", tcp: !Duel.unix_sockets?)
71
77
  config.prepare(:worker) do |w|
72
78
  program = DataDir.find_server(server) || w.failed("no #{server} on the PATH (give it as server:, or DUEL_MYSQL_SERVER)")
73
79
  data = w.path("data")
74
80
  DataDir.new(w, program).create(data)
81
+ # (A Unix socket even with +tcp+, which MySQL can't do without:
82
+ # its own default's in a directory of the system's.)
75
83
  socket = w.path("mysqld.sock")
76
- w.spawn(program, *DataDir.options(data), "--socket=#{socket}", "--pid-file=#{w.path("mysqld.pid")}", "--tmpdir=#{w.dir}",
77
- *(RUNNING + args))
78
- w.wait_until { Connection.ping(socket) }
79
- run(socket, setup) if setup
80
- url = "#{scheme}://#{USER}@localhost/#{DATABASE}?socket=#{socket}"
81
- {URL => url, SOCKET => socket}.merge(env.to_h { |name| [name, url] })
82
- end
83
- connection = config.in_worker { |w| Connection.new(socket).tap { |mysql| w.at_stop { mysql.close } } }
84
+ if tcp
85
+ port = w.port
86
+ listen = ["--port=#{port}", "--bind-address=127.0.0.1", "--socket=#{socket}"]
87
+ address = "127.0.0.1:#{port}"
88
+ url = "#{scheme}://#{USER}@127.0.0.1:#{port}/#{DATABASE}"
89
+ vars = {URL => url}
90
+ else
91
+ # (No network at all.)
92
+ address = socket
93
+ listen = ["--skip-networking", "--socket=#{socket}"]
94
+ url = "#{scheme}://#{USER}@localhost/#{DATABASE}?socket=#{address}"
95
+ vars = {URL => url, SOCKET => address}
96
+ end
97
+ w.spawn(program, *(DataDir.options(data) + listen), "--pid-file=#{w.path("mysqld.pid")}", "--tmpdir=#{w.dir}", *(RUNNING + args))
98
+ # (Stopped with SHUTDOWN, before it's killed: on Windows, mysqld is
99
+ # a monitor, the server its child, which killing it would leave
100
+ # running.)
101
+ w.at_stop { shutdown(address) }
102
+ w.wait_until { Connection.ping(address) }
103
+ run(address, setup) if setup
104
+ vars.merge(env.to_h { |name| [name, url] })
105
+ end
106
+ connection = config.in_worker { |w| Connection.new(address).tap { |mysql| w.at_stop { mysql.close } } }
84
107
  statements = Statements.new(connection)
85
108
  config.metric(METRICS) { statements.read }.costly.details { |stretches, sample| statements.details(stretches, sample.n) }
86
109
  connection
87
110
  end
88
111
 
89
- # Loads Trilogy, as the first connection is made: not as the plugin
90
- # loads, in .duel.rb, before a worker loads its version. In trilogy's
91
- # own repository, trilogy is what's measured, and the worker would load
92
- # whichever trilogy the load path led to first (the bundle's release,
93
- # say), and keep it. (In the runner, which loads no version, the
94
- # bundle's.)
95
- # mutant:disable -- the tests' process has Trilogy loaded from the start,
96
- # so a require changes nothing there: test_loads_trilogy_only_when_used
97
- # checks it, in a process of its own
98
- def self.require_trilogy = require("trilogy")
99
-
100
- # Runs SQL on a connection of its own to the server on +socket+;
101
- # returns the last statement's result.
102
- def self.run(socket, sql)
103
- connection = Connection.new(socket)
112
+ # Runs SQL on a connection of its own to the server at +address+ (its
113
+ # socket's path, or HOST:PORT); returns the last statement's result.
114
+ def self.run(address, sql)
115
+ connection = Connection.new(address)
104
116
  begin
105
117
  connection.execute(sql)
106
118
  ensure
@@ -108,6 +120,13 @@ module Duel
108
120
  end
109
121
  end
110
122
 
123
+ # Asks the server at +address+ to shut down, if it's there to ask.
124
+ def self.shutdown(address)
125
+ run(address, "SHUTDOWN")
126
+ rescue Error, SystemCallError, IOError
127
+ nil # (gone already, or gone as it answered)
128
+ end
129
+
111
130
  # Server time isn't the worker's CPU time: another process's, on the
112
131
  # clock, so what else the machine does shows in it. It's judged on
113
132
  # each benchmark, but left out across the board, where the margin is
@@ -167,7 +186,7 @@ module Duel
167
186
  # (Connection#quote'd: the plugin's own readings'). A statement's run
168
187
  # (LAST_SEEN) is when it ended, but it's counted just after.
169
188
  DIGESTS = <<~SQL
170
- SELECT DIGEST, COUNT_STAR, SUM_ROWS_SENT + SUM_ROWS_AFFECTED, SUM_ROWS_EXAMINED, SUM_TIMER_WAIT
189
+ SELECT COUNT_STAR, SUM_ROWS_SENT + SUM_ROWS_AFFECTED, SUM_ROWS_EXAMINED, SUM_TIMER_WAIT, DIGEST
171
190
  FROM performance_schema.events_statements_summary_by_digest
172
191
  WHERE DIGEST IS NOT NULL AND UNIX_TIMESTAMP(LAST_SEEN) >= %d AND DIGEST NOT IN (%s)
173
192
  SQL
@@ -194,13 +213,10 @@ module Duel
194
213
  end
195
214
  end
196
215
 
197
- # The same by measure (time in µs).
198
- def self.stats(connection) = Statements.by_measure(totals(connection))
199
-
200
216
  # What the server has done so far, by statement, read over
201
217
  # +connection+: those run since +since+ (seconds since the epoch), but
202
- # the +own+ digests, each one's [digest, queries, rows, rows examined,
203
- # time (ps)].
218
+ # the +own+ digests, each one's [queries, rows, rows examined, time
219
+ # (ps), digest].
204
220
  def self.digests(connection, since, own)
205
221
  connection.query(format(DIGESTS, since, own.map { |digest| connection.quote(digest) }.join(", "))).rows
206
222
  end
@@ -217,26 +233,35 @@ module Duel
217
233
  # For benchmarks: the worker's server.
218
234
  def self.url = ENV.fetch(URL)
219
235
 
220
- # Its socket's path (for a client that takes it, not a URL).
236
+ # Its socket's path (for a client that takes it, not a URL). With
237
+ # +tcp+, there's none (see .url).
221
238
  def self.socket = ENV.fetch(SOCKET)
222
239
 
240
+ # Where it is, for the plugin's own connections: its socket's path, or
241
+ # (with +tcp+) its URL's HOST:PORT, in +env+ (a worker's).
242
+ def self.address(env = ENV)
243
+ # (Or the URL's: one the plugin made, so it has a HOST:PORT, which
244
+ # Steep can't tell.)
245
+ env.fetch(SOCKET) { env.fetch(URL)[%r{@([^/]+)/}, 1] } # steep:ignore BlockBodyTypeMismatch
246
+ end
247
+
223
248
  # Runs SQL (statements, ;-separated) on it, over a connection of its
224
249
  # own; returns the last one's result. For setting up: it fails while
225
250
  # a benchmark is measured (Duel.measuring?), as what it runs would be
226
251
  # counted.
227
252
  def self.execute(sql)
228
253
  Duel.unmeasured!("Duel::MySQL.execute")
229
- run(socket, sql)
254
+ run(address, sql)
230
255
  end
231
256
 
232
257
  # Empties every table in its database, restarting their
233
258
  # AUTO_INCREMENTs. For setting up, as execute is.
234
259
  def self.reset
235
260
  Duel.unmeasured!("Duel::MySQL.reset")
236
- tables = run(socket, "SELECT table_name FROM information_schema.tables " \
261
+ tables = run(address, "SELECT table_name FROM information_schema.tables " \
237
262
  "WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'").map(&:first)
238
263
  # (Only this connection's: it's closed after.)
239
- run(socket, "SET FOREIGN_KEY_CHECKS = 0#{tables.map { |table| "; TRUNCATE TABLE `#{table}`" }.join}")
264
+ run(address, "SET FOREIGN_KEY_CHECKS = 0#{tables.map { |table| "; TRUNCATE TABLE `#{table}`" }.join}")
240
265
  end
241
266
 
242
267
  # Running totals of what the worker's server did, all told (#read),
@@ -251,10 +276,6 @@ module Duel
251
276
  SHOWN = 3
252
277
  TEXT = 80
253
278
 
254
- # A statement not read yet, as a row of MySQL.digests: it did
255
- # nothing.
256
- UNREAD = [nil, 0, 0, 0, 0].freeze
257
-
258
279
  # A statement that did nothing yet.
259
280
  NOTHING = [0, 0, 0, 0].freeze
260
281
 
@@ -264,9 +285,10 @@ module Duel
264
285
  # No statement changed.
265
286
  UNCHANGED = [] #: Array[String]
266
287
 
267
- # A reading's context: every statement's row as of it, by digest (a
268
- # Hash it shares with the last reading, if none changed), the last
269
- # reading's, and the digests of those that changed since.
288
+ # A reading's context: every statement's row as of it (its numbers,
289
+ # then its digest), by digest (a Hash it shares with the last
290
+ # reading, if none changed), the last reading's, and the digests of
291
+ # those that changed since.
270
292
  Reading = Data.define(:rows, :previous, :changed)
271
293
 
272
294
  # How long before a reading (in seconds) the next one reads the
@@ -340,7 +362,7 @@ module Duel
340
362
  rows = previous
341
363
  changed = UNCHANGED
342
364
  MySQL.digests(connection, since, own).each do |row|
343
- digest = row.fetch(0)
365
+ digest = row.last
344
366
  next if row == previous[digest]
345
367
 
346
368
  # (The last reading's Hash is its own: copied, at the first change.)
@@ -372,9 +394,9 @@ module Duel
372
394
  digests = after.previous.equal?(before) ? after.changed : after.rows.keys
373
395
  digests.each do |digest|
374
396
  now = after.rows.fetch(digest)
375
- was = before.fetch(digest, UNREAD)
397
+ was = before.fetch(digest, NOTHING)
376
398
  so_far = grew.fetch(digest, NOTHING)
377
- grew[digest] = Array.new(NAMES.size) { |i| so_far.fetch(i) + now.fetch(i + 1) - was.fetch(i + 1) }
399
+ grew[digest] = Array.new(NAMES.size) { |i| so_far.fetch(i) + now.fetch(i) - was.fetch(i) }
378
400
  end
379
401
  end
380
402
  grew.select { |_, more| more.any?(&:positive?) }
@@ -391,46 +413,379 @@ module Duel
391
413
  def shorten(text) = (text.length > TEXT) ? "#{text[0, TEXT - 1]}…" : text
392
414
  end
393
415
 
394
- # A connection to a worker's server, as root, to its database.
416
+ # What a connection to a worker's server raises where it fails: a
417
+ # statement's error (its code and message), or a reply it can't read.
418
+ class Error < Duel::Error
419
+ # The server's error code, or nil (not the server's error).
420
+ attr_reader :code
421
+
422
+ def initialize(message, code: nil)
423
+ super(message)
424
+ @code = code
425
+ end
426
+ end
427
+
428
+ # A query's result: its columns' names, and its rows, each value a
429
+ # String, but an integer column's an Integer, a floating-point one's a
430
+ # Float, and NULL nil. (One that returns none, an INSERT's, say, has
431
+ # neither.)
432
+ class Result
433
+ include Enumerable
434
+
435
+ attr_reader :fields, :rows
436
+
437
+ # (Given in order, not by keyword: a keyword's Hash would be made for
438
+ # every query.)
439
+ def initialize(fields, rows)
440
+ @fields = fields
441
+ @rows = rows
442
+ end
443
+
444
+ def each(&) = rows.each(&)
445
+ end
446
+
447
+ # The least a connection needs to read a server's statistics: not the
448
+ # code's own, whose statements are what's measured. As root (with no
449
+ # password: the data directory's initialized with none), to its
450
+ # database, over its Unix socket (a path), or over TCP (HOST:PORT: on
451
+ # Windows), in MySQL's text protocol: statements, several to a query
452
+ # if need be, and their results, the last one's returned.
395
453
  class Connection
396
- # Whether a server answers on +socket+.
397
- def self.ping(socket)
398
- new(socket).close
399
- rescue Trilogy::Error
454
+ # What the client says it can do: protocol 4.1's packets, a
455
+ # database to connect to, transactions' statuses, 4.1's (and 8.0's)
456
+ # authentication, several statements to a query, and their results.
457
+ LONG_PASSWORD = 0x1
458
+ CONNECT_WITH_DB = 0x8
459
+ PROTOCOL_41 = 0x200
460
+ TRANSACTIONS = 0x2000
461
+ SECURE_CONNECTION = 0x8000
462
+ MULTI_STATEMENTS = 0x10000
463
+ MULTI_RESULTS = 0x20000
464
+ PLUGIN_AUTH = 0x80000
465
+ CAPABILITIES = LONG_PASSWORD | CONNECT_WITH_DB | PROTOCOL_41 | TRANSACTIONS | SECURE_CONNECTION | MULTI_STATEMENTS | MULTI_RESULTS |
466
+ PLUGIN_AUTH
467
+ # The largest packet it takes, and its character set (utf8mb4).
468
+ MAX_PACKET = (1 << 24) - 1
469
+ UTF8MB4 = 45
470
+
471
+ # A packet's first byte: an OK, an error, an end of rows (EOF, of
472
+ # fewer than 9 bytes), or more of authentication's (caching_sha2_
473
+ # password's: FAST_AUTH, the password matched what it had cached).
474
+ OK = 0x00
475
+ ERR = 0xFF
476
+ EOF = 0xFE
477
+ AUTH_SWITCH = 0xFE
478
+ AUTH_MORE = 0x01
479
+ FAST_AUTH = 0x03
480
+ COM_QUERY = 0x03
481
+ # A NULL value in a row, and lenenc integers' prefixes.
482
+ NULL = 0xFB
483
+ # An OK's or EOF's status: more results to come.
484
+ MORE_RESULTS = 0x08
485
+
486
+ # The column types read as Integers (TINY, SHORT, LONG, LONGLONG,
487
+ # INT24, YEAR) and as Floats (FLOAT, DOUBLE).
488
+ INTEGERS = [1, 2, 3, 8, 9, 13].freeze
489
+ FLOATS = [4, 5].freeze
490
+
491
+ # What the client says it is when the server's gone.
492
+ CLOSED = "MySQL closed the connection"
493
+
494
+ # How long, in seconds, it waits for the server's next packet before
495
+ # it gives up: a server that's stuck (or sent a packet's length
496
+ # wrong) would have it wait forever.
497
+ TIMEOUT = 10
498
+
499
+ # Whether a server answers at +address+.
500
+ def self.ping(address)
501
+ new(address).close
502
+ rescue Error, SystemCallError, IOError
400
503
  false
401
504
  end
402
505
 
403
- def initialize(socket)
404
- MySQL.require_trilogy
405
- # (As root: trilogy's user, unless it's given another.)
406
- @client = Trilogy.new(socket: socket, database: DATABASE, multi_statement: true)
506
+ # The host and port of a HOST:PORT address, or nil (a Unix socket's
507
+ # path).
508
+ def self.address(address)
509
+ match = %r{\A([^:/]+):(\d+)\z}.match(address) or return
510
+ [match[1], Integer(match[2])]
407
511
  end
408
512
 
409
- def query(sql) = @client.query(sql)
513
+ # A socket to +address+, without TCP's delay before a small write
514
+ # (a statement), whose reply would wait for it.
515
+ def self.socket(address)
516
+ host_and_port = address(address)
517
+ return UNIXSocket.new(address) unless host_and_port
410
518
 
411
- # +text+ as a string literal.
412
- def quote(text) = "'#{@client.escape(text)}'"
519
+ host, port = host_and_port
520
+ # (RBS's setsockopt takes an Integer for the value, but Ruby's
521
+ # takes true too.)
522
+ TCPSocket.new(host, port).tap { |socket| socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true) } # steep:ignore ArgumentTypeMismatch
523
+ end
413
524
 
414
- # Runs statements; returns the last one's result.
415
- def execute(sql)
416
- result = query(sql)
417
- result = @client.next_result while @client.more_results_exist?
418
- result
525
+ def initialize(address, database: DATABASE, timeout: TIMEOUT)
526
+ @socket = Connection.socket(address)
527
+ @timeout = timeout
528
+ # (Buffers of its own, binary (one byte a byte), read into
529
+ # and written from again and again: a packet's header, and its
530
+ # payload, which is read before the next one is, and what's written
531
+ # before a payload. Where the packet's read up to (@at), the last
532
+ # one's sequence number, and whether more results follow the last
533
+ # one read, are set as each is read.)
534
+ @header = "".b
535
+ @packet = "".b
536
+ @out = "".b
537
+ begin
538
+ authenticate(database)
539
+ rescue Exception # rubocop:disable Lint/RescueException
540
+ close
541
+ raise
542
+ end
543
+ end
544
+
545
+ # Runs +sql+ (statements, ;-separated); returns the last one's
546
+ # result. A statement that fails raises its Error.
547
+ def query(sql)
548
+ write(sql, 0, COM_QUERY)
549
+ loop do
550
+ result = next_result
551
+ return result unless @more
552
+ end
419
553
  end
420
554
 
555
+ # Runs statements; returns the last one's result.
556
+ def execute(sql) = query(sql)
557
+
558
+ # +text+ as a string literal.
559
+ def quote(text) = "'#{text.gsub(/[\0\n\r\\'"\x1a]/, ESCAPES)}'"
560
+
561
+ ESCAPES = {"\0" => "\\0", "\n" => "\\n", "\r" => "\\r", "\\" => "\\\\", "'" => "\\'", "\"" => "\\\"", "\x1a" => "\\Z"}.freeze
562
+
421
563
  # Closes it without telling the server (no QUIT, which the server
422
564
  # could read after a benchmark's started, and count); true.
423
- def close = @client.discard!
565
+ def close
566
+ @socket.close
567
+ true
568
+ end
569
+
570
+ private
571
+
572
+ # The server's greeting (a handshake, protocol 10), and the client's
573
+ # reply: root, with no password (an empty response, whichever plugin
574
+ # the server authenticates with), to +database+. Fails unless it's
575
+ # let in.
576
+ def authenticate(database)
577
+ greeting = read
578
+ error!(greeting) if greeting.getbyte(0) == ERR
579
+ # (Its last string: the scramble before it has no NUL in it.)
580
+ plugin = greeting.split("\0").last #: String
581
+ # (23 bytes reserved, and the response's length, 0, before the
582
+ # database.)
583
+ # (The greeting's numbered 0, and the reply 1.)
584
+ write([CAPABILITIES, MAX_PACKET, UTF8MB4, USER, database, plugin].pack("VVCx23Z*xZ*Z*"), 1)
585
+ loop do
586
+ reply = read
587
+ case reply.getbyte(0)
588
+ when OK then return
589
+ when ERR then error!(reply)
590
+ # (Another plugin: an empty response again.)
591
+ when AUTH_SWITCH then write("", @sequence + 1)
592
+ # (caching_sha2_password's: the empty password matched.)
593
+ when AUTH_MORE then raise Error, "MySQL wants a password (root's has none)" unless reply.getbyte(1) == FAST_AUTH
594
+ else raise Error, "MySQL: an authentication reply the connection doesn't read: #{reply.getbyte(0)}"
595
+ end
596
+ end
597
+ end
598
+
599
+ # A statement's result (and in @more, whether more follow): an OK's
600
+ # (no rows), or a result set's (its columns, then its rows, each
601
+ # ended by an EOF). An error raises it.
602
+ def next_result
603
+ packet = read
604
+ case packet.getbyte(0)
605
+ when OK
606
+ # (Its status after its affected rows and insert id.)
607
+ @at = 1
608
+ lenenc(packet)
609
+ lenenc(packet)
610
+ @more = more?(packet, @at)
611
+ Result.new(NONE, NONE)
612
+ when ERR then error!(packet)
613
+ else
614
+ @at = 0
615
+ count = lenenc(packet)
616
+ names = [] #: Array[String]
617
+ types = [] #: Array[Integer]
618
+ count.times { column(read, names, types) }
619
+ read # (the columns' EOF)
620
+ rows = [] #: Array[Array[untyped]]
621
+ rows << row(packet, types) until eof?(packet = read)
622
+ # (Its status after its warnings.)
623
+ @more = more?(packet, 3)
624
+ Result.new(names, rows)
625
+ end
626
+ end
627
+
628
+ # An OK's result: no fields, and no rows.
629
+ NONE = Array.new(0).freeze
630
+
631
+ # Whether an OK's or an EOF's status, at +at+, says more results
632
+ # follow. (Its first byte, of two, little-endian, has the flag.)
633
+ def more?(packet, at)
634
+ status = packet.getbyte(at) #: Integer
635
+ (status & MORE_RESULTS).positive?
636
+ end
637
+
638
+ # An EOF: one of fewer than 9 bytes that starts with EOF (a row can
639
+ # too, with a value's 8-byte length).
640
+ def eof?(packet) = packet.getbyte(0) == EOF && packet.bytesize < 9
641
+
642
+ # A column's name and its type, added to +names+ and +types+: after
643
+ # four lenenc strings (its catalog, schema, table, original table),
644
+ # its name, its original name, and its fixed fields' length, its
645
+ # character set (2 bytes) and length (4), then its type.
646
+ def column(packet, names, types)
647
+ @at = 0
648
+ 4.times { skip(packet) }
649
+ names << string(packet, lenenc(packet)).force_encoding(Encoding::UTF_8)
650
+ skip(packet)
651
+ lenenc(packet)
652
+ type = packet.getbyte(@at + 6) #: Integer
653
+ types << type
654
+ end
655
+
656
+ # A row's values, by its columns' +types+.
657
+ def row(packet, types)
658
+ @at = 0
659
+ types.map do |type|
660
+ if packet.getbyte(@at) == NULL
661
+ @at += 1
662
+ next
663
+ end
664
+
665
+ length = lenenc(packet)
666
+ if INTEGERS.include?(type)
667
+ integer(packet, length)
668
+ elsif FLOATS.include?(type)
669
+ Float(string(packet, length))
670
+ else
671
+ string(packet, length).force_encoding(Encoding::UTF_8)
672
+ end
673
+ end
674
+ end
675
+
676
+ # The integer written (in decimal, with a sign if it's negative) in
677
+ # the +length+ bytes at the packet's @at, read on past them. (Read
678
+ # byte by byte, so that no String is made of them.)
679
+ def integer(packet, length)
680
+ stop = @at + length
681
+ negative = packet.getbyte(@at) == MINUS
682
+ @at += 1 if negative
683
+ value = 0
684
+ while @at < stop
685
+ digit = packet.getbyte(@at) #: Integer
686
+ value = (value * 10) + digit - ZERO
687
+ @at += 1
688
+ end
689
+ negative ? -value : value
690
+ end
691
+
692
+ # A minus sign's byte, and a 0's.
693
+ MINUS = 0x2D
694
+ ZERO = 0x30
695
+
696
+ # The +length+ bytes at the packet's @at, as a String of their own,
697
+ # read on past them.
698
+ def string(packet, length)
699
+ string = packet.byteslice(@at, length) #: String
700
+ @at += length
701
+ string
702
+ end
703
+
704
+ # A length-encoded string at the packet's @at, skipped. (Its length
705
+ # read first: it moves @at past itself.)
706
+ def skip(packet)
707
+ length = lenenc(packet)
708
+ @at += length
709
+ end
710
+
711
+ # The length-encoded integer at the packet's @at, read on past it.
712
+ def lenenc(packet)
713
+ at = @at
714
+ first = packet.getbyte(at) #: Integer
715
+ # (Looked up, not fetched with a block, which would make a Proc
716
+ # for each one read.)
717
+ size = LENGTHS[first]
718
+ unless size
719
+ @at = at + 1
720
+ return first
721
+ end
722
+ # (Its bytes, little-endian.)
723
+ value = 0
724
+ size.times do |i|
725
+ byte = packet.getbyte(at + 1 + i) #: Integer
726
+ value += byte << (8 * i)
727
+ end
728
+ @at = at + 1 + size
729
+ value
730
+ end
731
+
732
+ # A length-encoded integer's prefixes, and its bytes after them (one
733
+ # under 0xFB is the integer itself).
734
+ LENGTHS = {0xFC => 2, 0xFD => 3, 0xFE => 8}.freeze
735
+
736
+ # The next packet's payload (in a buffer that the one after it is
737
+ # read into), its sequence number in @sequence.
738
+ def read
739
+ # (Its length in 3 bytes, then its sequence number.)
740
+ header = read_exactly(4, @header).unpack1("V") #: Integer
741
+ @sequence = header >> 24
742
+ read_exactly(header & MAX_PACKET, @packet)
743
+ end
744
+
745
+ def read_exactly(size, buffer)
746
+ raise IOError, "MySQL didn't answer in #{@timeout} seconds" unless @socket.wait_readable(@timeout)
747
+
748
+ data = @socket.read(size, buffer)
749
+ raise IOError, CLOSED unless data && data.bytesize == size
750
+
751
+ data
752
+ end
753
+
754
+ # Writes a packet: +payload+, after +command+'s byte if there's one,
755
+ # numbered +sequence+. (Its header: its length in 3 bytes, then its
756
+ # sequence number.)
757
+ def write(payload, sequence, command = nil)
758
+ size = payload.bytesize + (command ? 1 : 0)
759
+ out = @out.clear
760
+ out << (size & 0xFF) << ((size >> 8) & 0xFF) << (size >> 16) << sequence
761
+ out << command if command
762
+ @socket.write(out, payload)
763
+ end
764
+
765
+ # Raises an error packet's error: its code (2 bytes), its SQL state
766
+ # (# and 5 characters), and its message.
767
+ def error!(packet)
768
+ code = packet.unpack1("v", offset: 1) #: Integer
769
+ start = (packet.getbyte(3) == 35) ? 9 : 3 # (after the SQL state, where there's one)
770
+ message = packet.byteslice(start..) #: String
771
+ message.force_encoding(Encoding::UTF_8)
772
+ raise Error.new("MySQL: #{message} (#{code})", code: code)
773
+ end
424
774
  end
425
775
 
426
776
  # A worker's data directory: a copy of one initialized once, with the
427
777
  # database created in it.
428
778
  class DataDir
429
- # The server program: +server+ if it's a path, or the one by that
430
- # name on +path+; nil if there's none.
431
- def self.find_server(server, path = ENV.fetch("PATH", ""))
432
- files = server.include?(File::SEPARATOR) ? [server] : path.split(File::PATH_SEPARATOR).map { |dir| File.join(dir, server) }
433
- files.find { |file| File.executable?(file) }
779
+ # A program's file ends with +EXE+: on Windows, .exe.
780
+ EXE = RbConfig::CONFIG["EXEEXT"]
781
+
782
+ # The server program: +server+ if it's a path (a / or, on Windows, a
783
+ # \ in it), or the one by that name on +path+; nil if there's none.
784
+ # Either may end with +exe+ too (on Windows, .exe: mysqld.exe, for
785
+ # mysqld).
786
+ def self.find_server(server, path = ENV.fetch("PATH", ""), exe: EXE)
787
+ files = server.match?(%r{[/\\]}) ? [server] : path.split(File::PATH_SEPARATOR).map { |dir| File.join(dir, server) }
788
+ files.flat_map { |file| [file, "#{file}#{exe}"] }.find { |file| File.executable?(file) }
434
789
  end
435
790
 
436
791
  # The options the server's run with, initializing +data+ or not.
data/sig/duel/mysql.rbs CHANGED
@@ -38,26 +38,27 @@ module Duel
38
38
  # rows examined, time (ps).
39
39
  type numbers = Array[Integer]
40
40
 
41
- # A statement's row, as MySQL.digests reads it: [digest, *numbers].
41
+ # A statement's row, as MySQL.digests reads it: [*numbers, digest].
42
42
  type row = Array[untyped]
43
43
 
44
44
  # Configures Duel for the plugin (c.use :mysql): the server (+server+
45
45
  # the program, +args+ more of its options, +setup+ SQL each worker's
46
46
  # database runs when it's started, +env+ the variables besides
47
- # DUEL_MYSQL_URL given its URL, +scheme+ the URL's) and its metrics.
48
- # Returns the plugin's own connection to it, a worker's.
47
+ # DUEL_MYSQL_URL given its URL, +scheme+ the URL's, +tcp+ on a port
48
+ # of 127.0.0.1's: by default on Windows) and its metrics. Returns the
49
+ # plugin's own connection to it, a worker's.
49
50
  def self.configure: (Config config, ?server: String, ?args: Array[String], ?setup: String?, ?env: Array[String],
50
- ?scheme: String) -> InWorker[Connection]
51
-
52
- # Runs SQL on a connection of its own to the server on +socket+;
53
- # returns the last statement's result.
54
- # Loads Trilogy, as the first connection is made.
55
- def self.require_trilogy: () -> bool
51
+ ?scheme: String, ?tcp: bool) -> InWorker[Connection]
56
52
 
57
53
  # The most memory a worker's server takes.
58
54
  def self.worker_memory: () -> Integer
59
55
 
60
- def self.run: (String socket, String sql) -> ::Trilogy::Result
56
+ # Runs SQL on a connection of its own to the server at +address+;
57
+ # returns the last statement's result.
58
+ def self.run: (String address, String sql) -> Result
59
+
60
+ # Asks the server at +address+ to shut down, if it's there to ask.
61
+ def self.shutdown: (String address) -> void
61
62
 
62
63
  # What the worker's server has done so far, but for the plugin's own
63
64
  # connection, which reads it.
@@ -67,12 +68,9 @@ module Duel
67
68
  # running a statement.
68
69
  def self.settle: (Connection connection) -> void
69
70
 
70
- # The same by measure.
71
- def self.stats: (Connection connection) -> Snapshot::totals[Metric::value]
72
-
73
71
  # What the server has done so far, by statement, read over
74
72
  # +connection+: those run since +since+, but the +own+ digests, each
75
- # one's [digest, *numbers].
73
+ # one's [*numbers, digest].
76
74
  def self.digests: (Connection connection, Integer since, Array[String] own) -> Array[row]
77
75
 
78
76
  # The digest of each of +statements+, read over +connection+.
@@ -88,13 +86,23 @@ module Duel
88
86
  # Its socket's path.
89
87
  def self.socket: () -> String
90
88
 
89
+ # The environment (ENV, or a Hash in its place).
90
+ interface _Env
91
+ def fetch: (String name) -> String
92
+ | (String name) { (String name) -> String } -> String
93
+ end
94
+
95
+ # Where it is, for the plugin's own connections: its socket's path, or
96
+ # its URL's HOST:PORT.
97
+ def self.address: (?_Env env) -> String
98
+
91
99
  # Runs SQL on it, over a connection of its own; returns the last
92
100
  # statement's result. For setting up: it fails while a benchmark is
93
101
  # measured.
94
- def self.execute: (String sql) -> ::Trilogy::Result
102
+ def self.execute: (String sql) -> Result
95
103
 
96
104
  # Empties every table in its database. For setting up, as execute is.
97
- def self.reset: () -> ::Trilogy::Result
105
+ def self.reset: () -> Result
98
106
 
99
107
  # Running totals of what the worker's server did, all told, and by
100
108
  # statement, to explain a regression.
@@ -107,9 +115,6 @@ module Duel
107
115
  SHOWN: Integer
108
116
  TEXT: Integer
109
117
 
110
- # A statement not read yet, as a row of MySQL.digests.
111
- UNREAD: row
112
-
113
118
  # A statement that did nothing yet.
114
119
  NOTHING: numbers
115
120
 
@@ -169,35 +174,136 @@ module Duel
169
174
  def shorten: (String text) -> String
170
175
  end
171
176
 
172
- # A connection to a worker's server, as root, to its database.
173
- class Connection
174
- @client: ::Trilogy
177
+ # What a connection to a worker's server raises where it fails.
178
+ class Error < Duel::Error
179
+ @code: Integer?
175
180
 
176
- # Whether a server answers on +socket+.
177
- def self.ping: (String socket) -> bool
181
+ # The server's error code, or nil.
182
+ attr_reader code: Integer?
178
183
 
179
- def initialize: (String socket) -> void
184
+ def initialize: (String message, ?code: Integer?) -> void
185
+ end
180
186
 
181
- def query: (String sql) -> ::Trilogy::Result
187
+ # A query's result: its columns' names, and its rows.
188
+ class Result
189
+ include Enumerable[Array[untyped]]
182
190
 
183
- # +text+ as a string literal.
184
- def quote: (String text) -> String
191
+ attr_reader fields: Array[String]
192
+ attr_reader rows: Array[Array[untyped]]
193
+
194
+ def initialize: (Array[String] fields, Array[Array[untyped]] rows) -> void
195
+
196
+ def each: () { (Array[untyped] row) -> void } -> Array[Array[untyped]]
197
+ end
198
+
199
+ # The least a connection needs to read a server's statistics, in
200
+ # MySQL's text protocol: as root, to its database.
201
+ class Connection
202
+ LONG_PASSWORD: Integer
203
+ CONNECT_WITH_DB: Integer
204
+ PROTOCOL_41: Integer
205
+ TRANSACTIONS: Integer
206
+ SECURE_CONNECTION: Integer
207
+ MULTI_STATEMENTS: Integer
208
+ MULTI_RESULTS: Integer
209
+ PLUGIN_AUTH: Integer
210
+ CAPABILITIES: Integer
211
+ MAX_PACKET: Integer
212
+ UTF8MB4: Integer
213
+ OK: Integer
214
+ ERR: Integer
215
+ EOF: Integer
216
+ AUTH_SWITCH: Integer
217
+ AUTH_MORE: Integer
218
+ FAST_AUTH: Integer
219
+ COM_QUERY: Integer
220
+ NULL: Integer
221
+ MORE_RESULTS: Integer
222
+ INTEGERS: Array[Integer]
223
+ FLOATS: Array[Integer]
224
+ CLOSED: String
225
+ TIMEOUT: Integer
226
+ ESCAPES: Hash[String, String]
227
+ LENGTHS: Hash[Integer, Integer]
228
+ NONE: Array[untyped]
229
+ MINUS: Integer
230
+ ZERO: Integer
231
+
232
+ @socket: UNIXSocket | TCPSocket
233
+ @timeout: Integer | Float
234
+ @header: String
235
+ @packet: String
236
+ @out: String
237
+ @at: Integer
238
+ @sequence: Integer
239
+ @more: bool
240
+
241
+ # Whether a server answers at +address+.
242
+ def self.ping: (String address) -> bool
243
+
244
+ # The host and port of a HOST:PORT address, or nil.
245
+ def self.address: (String address) -> [String, Integer]?
246
+
247
+ # A socket to +address+.
248
+ def self.socket: (String address) -> (UNIXSocket | TCPSocket)
249
+
250
+ def initialize: (String address, ?database: String, ?timeout: Integer | Float) -> void
251
+
252
+ def query: (String sql) -> Result
185
253
 
186
254
  # Runs statements; returns the last one's result.
187
- def execute: (String sql) -> ::Trilogy::Result
255
+ def execute: (String sql) -> Result
256
+
257
+ # +text+ as a string literal.
258
+ def quote: (String text) -> String
188
259
 
189
260
  # Closes it without telling the server (no QUIT); true.
190
261
  def close: () -> bool
262
+
263
+ private
264
+
265
+ def authenticate: (String database) -> void
266
+
267
+ # A statement's result (and in @more, whether more follow).
268
+ def next_result: () -> Result
269
+
270
+ def more?: (String packet, Integer at) -> bool
271
+
272
+ def eof?: (String packet) -> bool
273
+
274
+ # A column's name and its type, the +i+th of +names+ and +types+.
275
+ def column: (String packet, Array[String] names, Array[Integer] types) -> Array[Integer]
276
+
277
+ def row: (String packet, Array[Integer] types) -> Array[untyped]
278
+
279
+ def integer: (String packet, Integer length) -> Integer
280
+
281
+ def string: (String packet, Integer length) -> String
282
+
283
+ def skip: (String packet) -> Integer
284
+
285
+ def lenenc: (String packet) -> Integer
286
+
287
+ # The next packet's payload.
288
+ def read: () -> String
289
+
290
+ def read_exactly: (Integer size, String buffer) -> String
291
+
292
+ def write: (String payload, Integer sequence, ?Integer? command) -> Integer
293
+
294
+ def error!: (String packet) -> bot
191
295
  end
192
296
 
193
297
  # A worker's data directory: a copy of one initialized once.
194
298
  class DataDir
299
+ EXE: String
300
+
195
301
  @resource: Resource
196
302
  @server: String
197
303
 
198
304
  # The server program: +server+ if it's a path, or the one by that
199
- # name on +path+; nil if there's none.
200
- def self.find_server: (String server, ?String path) -> String?
305
+ # name on +path+ (either may end with +exe+ too); nil if there's none.
306
+ def self.find_server: (String server, ?String path, ?exe: String) -> String?
201
307
 
202
308
  # The options the server's run with, initializing a data directory
203
309
  # or not.
metadata CHANGED
@@ -1,80 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duel-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
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
- name: duel
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '0.1'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: '0.1'
26
- - !ruby/object:Gem::Dependency
27
- name: trilogy
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: '2.9'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '2.9'
40
- description: 'A Duel plugin: each worker gets a MySQL server of its own, and every
41
- benchmark is judged on the statements it sent, the rows they read and their time
42
- too.'
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 MySQL server of its own, and every benchmark is judged on the statements it sent, the rows they read and their time too."
43
29
  email:
44
- - sferik@gmail.com
30
+ - sferik@gmail.com
45
31
  executables: []
46
32
  extensions: []
47
33
  extra_rdoc_files: []
48
34
  files:
49
- - CHANGELOG.md
50
- - LICENSE
51
- - README.md
52
- - lib/duel/mysql.rb
53
- - lib/duel/mysql/version.rb
54
- - sig/duel/mysql.rbs
55
- homepage: https://github.com/sferik/duel-ruby/tree/main/plugins/mysql
35
+ - CHANGELOG.md
36
+ - LICENSE
37
+ - README.md
38
+ - lib/duel/mysql.rb
39
+ - lib/duel/mysql/version.rb
40
+ - sig/duel/mysql.rbs
41
+ homepage: "https://github.com/sferik/duel-ruby/tree/main/plugins/mysql"
56
42
  licenses:
57
- - MIT
43
+ - MIT
58
44
  metadata:
59
- source_code_uri: https://github.com/sferik/duel-ruby/tree/main/plugins/mysql
60
- changelog_uri: https://github.com/sferik/duel-ruby/blob/main/plugins/mysql/CHANGELOG.md
61
- bug_tracker_uri: https://github.com/sferik/duel-ruby/issues
62
- rubygems_mfa_required: 'true'
45
+ source_code_uri: "https://github.com/sferik/duel-ruby/tree/main/plugins/mysql"
46
+ changelog_uri: "https://github.com/sferik/duel-ruby/blob/main/plugins/mysql/CHANGELOG.md"
47
+ bug_tracker_uri: "https://github.com/sferik/duel-ruby/issues"
48
+ rubygems_mfa_required: "true"
63
49
  rdoc_options: []
64
50
  require_paths:
65
- - lib
51
+ - lib
66
52
  required_ruby_version: !ruby/object:Gem::Requirement
67
53
  requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: '3.4'
54
+ -
55
+ - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "3.4"
71
58
  required_rubygems_version: !ruby/object:Gem::Requirement
72
59
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
60
+ -
61
+ - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
76
64
  requirements: []
77
- rubygems_version: 4.0.24
65
+ rubygems_version: 4.1.0
78
66
  specification_version: 4
79
- summary: A MySQL server for each Duel worker, and what it did for each benchmark
67
+ summary: "A MySQL server for each Duel worker, and what it did for each benchmark"
80
68
  test_files: []