Skip to content

Commit b35988f

Browse files
authored
[ruby/roda-sequel] Use trilogy for the MySQL adapter (#10068)
Trilogy is a new client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding. It is used by Github and Shopify in production and will probably replace the mysql2 library. https://github.com/trilogy-libraries/trilogy
1 parent ac10006 commit b35988f

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

frameworks/Ruby/roda-sequel/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem "roda", "~> 3.66"
77
gem "tilt", "~> 2.1", require: "tilt/erb"
88

99
group :mysql, optional: true do
10-
gem "mysql2", "~> 0.5", platforms: %i[ruby windows]
10+
gem 'trilogy', '~> 2.9.0', platforms: [:ruby, :windows]
1111
end
1212

1313
group :postgresql, optional: true do

frameworks/Ruby/roda-sequel/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ GEM
55
erubi (1.13.1)
66
iodine (0.7.58)
77
json (2.13.2)
8-
mysql2 (0.5.6)
98
nio4r (2.7.4)
109
pg (1.5.9)
1110
puma (6.6.0)
@@ -19,6 +18,7 @@ GEM
1918
pg (>= 0.18.0, != 1.2.0)
2019
sequel (>= 4.38.0)
2120
tilt (2.6.0)
21+
trilogy (2.9.0)
2222

2323
PLATFORMS
2424
ruby
@@ -29,13 +29,13 @@ DEPENDENCIES
2929
erubi (~> 1.12)
3030
iodine (~> 0.7)
3131
json (~> 2.8)
32-
mysql2 (~> 0.5)
3332
pg (~> 1.4)
3433
puma (~> 6.2)
3534
roda (~> 3.66)
3635
sequel (~> 5.67)
3736
sequel_pg (~> 1.17)
3837
tilt (~> 2.1)
38+
trilogy (~> 2.9.0)
3939

4040
BUNDLED WITH
4141
2.7.0

frameworks/Ruby/roda-sequel/boot.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
def connect(dbtype)
2323
Bundler.require(dbtype) # Load database-specific modules
2424

25-
adapters = {
26-
mysql: {
27-
mri: "mysql2"
28-
},
29-
postgresql: {
30-
mri: "postgres"
31-
}
32-
}
33-
3425
opts = {}
3526

27+
if dbtype == :mysql
28+
adapter = 'trilogy'
29+
opts[:ssl] = true
30+
opts[:ssl_mode] = 4 # Trilogy::SSL_PREFERRED_NOVERIFY
31+
opts[:tls_min_version] = 3 # Trilogy::TLS_VERSION_12
32+
else
33+
adapter = 'postgresql'
34+
end
35+
3636
# Determine threading/thread pool size and timeout
3737
if defined?(Puma) &&
3838
(threads = Puma.cli_config.options.fetch(:max_threads)) > 1
@@ -42,8 +42,7 @@ def connect(dbtype)
4242

4343
Sequel.connect "%{adapter}://%{host}/%{database}?user=%{user}&password=%{password}" %
4444
{
45-
adapter:
46-
adapters.fetch(dbtype).fetch(:mri),
45+
adapter: adapter,
4746
host: "tfb-database",
4847
database: "hello_world",
4948
user: "benchmarkdbuser",

0 commit comments

Comments
 (0)