Browse Source

[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
Roman Samoilov 10 months ago
parent
commit
dc0bded626

+ 1 - 1
frameworks/Ruby/rage/Gemfile

@@ -1,6 +1,6 @@
 source "https://rubygems.org"
 source "https://rubygems.org"
 
 
-gem "rage-rb", "~> 1.3"
+gem "rage-rb", "~> 1.10"
 
 
 gem "pg", "~> 1.0"
 gem "pg", "~> 1.0"
 gem "activerecord", "~> 7.2.0", require: "active_record"
 gem "activerecord", "~> 7.2.0", require: "active_record"

+ 0 - 4
frameworks/Ruby/rage/app/models/fortune.rb

@@ -1,7 +1,3 @@
 class Fortune < ApplicationRecord
 class Fortune < ApplicationRecord
   self.table_name = "Fortune"
   self.table_name = "Fortune"
-
-  def as_json(*)
-    attributes
-  end
 end
 end

+ 0 - 4
frameworks/Ruby/rage/app/models/world.rb

@@ -1,9 +1,5 @@
 class World < ApplicationRecord
 class World < ApplicationRecord
   self.table_name = "World"
   self.table_name = "World"
 
 
-  def as_json(*)
-    attributes
-  end
-
   alias_attribute(:randomNumber, :randomnumber)
   alias_attribute(:randomNumber, :randomnumber)
 end
 end

+ 0 - 1
frameworks/Ruby/rage/config.ru

@@ -1,4 +1,3 @@
 require_relative "config/application"
 require_relative "config/application"
 
 
 run Rage.application
 run Rage.application
-Rage.load_middlewares(self)

+ 3 - 12
frameworks/Ruby/rage/config/initializers/activerecord.rb

@@ -2,16 +2,7 @@
 
 
 require "etc"
 require "etc"
 
 
-connection = {
-  adapter: "postgresql",
-  host: "tfb-database",
-  username: "benchmarkdbuser",
-  password: "benchmarkdbpass",
-  database: "hello_world",
-  reaping_frequency: 0,
-  pool: (2 * Math.log(256 / Etc.nprocessors)).floor
-}
+pool_size = (2 * Math.log(256 / Etc.nprocessors)).floor
+puts "ActiveRecord pool size: #{pool_size}"
 
 
-puts "ActiveRecord connection options: #{connection.inspect}"
-
-ActiveRecord::Base.establish_connection(connection)
+ENV["DATABASE_URL"]="postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world?pool=#{pool_size}&reaping_frequency=0"

+ 0 - 1
frameworks/Ruby/rage/rage.dockerfile

@@ -8,7 +8,6 @@ RUN bundle install --jobs=8
 COPY . /rage
 COPY . /rage
 
 
 ENV RUBY_YJIT_ENABLE=1
 ENV RUBY_YJIT_ENABLE=1
-ENV RAGE_PATCH_AR_POOL=1
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
 ENV BUNDLE_FORCE_RUBY_PLATFORM=true
 
 
 CMD bundle exec rage s -b 0.0.0.0 -p 8080 -e production
 CMD bundle exec rage s -b 0.0.0.0 -p 8080 -e production