Skip to content

Commit dc0bded

Browse files
authored
[ruby/rage] Code cleanup (#9305)
* Remove `load_middlewares` call `Rage.load_middlewares` was deprecated in v1.5 * Bump to Rage >= 1.10 * Remove `as_json` overrides * Remove env variable `RAGE_PATCH_AR_POOL` is enabled by default since v1.10 * Let Rage connect to the DB
1 parent b4ccb36 commit dc0bded

File tree

6 files changed

+4
-23
lines changed

6 files changed

+4
-23
lines changed

frameworks/Ruby/rage/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22

3-
gem "rage-rb", "~> 1.3"
3+
gem "rage-rb", "~> 1.10"
44

55
gem "pg", "~> 1.0"
66
gem "activerecord", "~> 7.2.0", require: "active_record"
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
class Fortune < ApplicationRecord
22
self.table_name = "Fortune"
3-
4-
def as_json(*)
5-
attributes
6-
end
73
end
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
class World < ApplicationRecord
22
self.table_name = "World"
33

4-
def as_json(*)
5-
attributes
6-
end
7-
84
alias_attribute(:randomNumber, :randomnumber)
95
end

frameworks/Ruby/rage/config.ru

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
require_relative "config/application"
22

33
run Rage.application
4-
Rage.load_middlewares(self)

frameworks/Ruby/rage/config/initializers/activerecord.rb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,7 @@
22

33
require "etc"
44

5-
connection = {
6-
adapter: "postgresql",
7-
host: "tfb-database",
8-
username: "benchmarkdbuser",
9-
password: "benchmarkdbpass",
10-
database: "hello_world",
11-
reaping_frequency: 0,
12-
pool: (2 * Math.log(256 / Etc.nprocessors)).floor
13-
}
5+
pool_size = (2 * Math.log(256 / Etc.nprocessors)).floor
6+
puts "ActiveRecord pool size: #{pool_size}"
147

15-
puts "ActiveRecord connection options: #{connection.inspect}"
16-
17-
ActiveRecord::Base.establish_connection(connection)
8+
ENV["DATABASE_URL"]="postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world?pool=#{pool_size}&reaping_frequency=0"

frameworks/Ruby/rage/rage.dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ RUN bundle install --jobs=8
88
COPY . /rage
99

1010
ENV RUBY_YJIT_ENABLE=1
11-
ENV RAGE_PATCH_AR_POOL=1
1211
ENV BUNDLE_FORCE_RUBY_PLATFORM=true
1312

1413
CMD bundle exec rage s -b 0.0.0.0 -p 8080 -e production

0 commit comments

Comments
 (0)