Browse Source

roda: update to ruby 2.7 (#6556)

* roda: update to ruby 2.7

* roda: remove torquebox
Ievgen Makukh 4 years ago
parent
commit
00c8b5b22f

+ 10 - 13
frameworks/Ruby/roda-sequel/Gemfile

@@ -1,22 +1,19 @@
 source 'https://rubygems.org'
 source 'https://rubygems.org'
 
 
-gem 'erubi', '~> 1.4'
-gem 'json', '~> 2.0'
-gem 'passenger', '~> 5.1', :platforms=>[:ruby, :mswin], :require=>false
-gem 'puma', '~> 3.9', :require=>false
-gem 'sequel', '~> 5.0'
-gem 'roda', '~> 3.0'
+gem 'erubi', '~> 1.10'
+gem 'json', '~> 2.5'
+gem 'passenger', '~> 6.0', :platforms=>[:ruby, :mswin], :require=>false
+gem 'puma', '~> 5.2', :require=>false
+gem 'sequel', '~> 5.44'
+gem 'roda', '~> 3.43'
 gem 'tilt', '~> 2.0', :require=>'tilt/erb'
 gem 'tilt', '~> 2.0', :require=>'tilt/erb'
-gem 'torquebox-web', '>= 4.0.0.beta3', '< 5', :platforms=>:jruby, :require=>false
-gem 'unicorn', '~> 5.2', :platforms=>[:ruby, :mswin], :require=>false
+gem 'unicorn', '~> 6.0', :platforms=>[:ruby, :mswin], :require=>false
 
 
 group :mysql do
 group :mysql do
-  gem 'jdbc-mysql', '~> 5.1', :platforms=>:jruby, :require=>'jdbc/mysql'
-  gem 'mysql2', '~> 0.4', :platforms=>[:ruby, :mswin]
+  gem 'mysql2', '~> 0.5', :platforms=>[:ruby, :mswin]
 end
 end
 
 
 group :postgresql do
 group :postgresql do
-  gem 'jdbc-postgres', '~> 9.4', :platforms=>:jruby, :require=>'jdbc/postgres'
-  gem 'pg', '~> 0.19', :platforms=>[:ruby, :mswin]
-  gem 'sequel_pg', '~> 1.6', :platforms=>:ruby, :require=>false
+  gem 'pg', '~> 1.2', :platforms=>[:ruby, :mswin]
+  gem 'sequel_pg', '~> 1.14', :platforms=>:ruby, :require=>false
 end
 end

+ 46 - 0
frameworks/Ruby/roda-sequel/Gemfile.lock

@@ -0,0 +1,46 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    erubi (1.10.0)
+    json (2.5.1)
+    kgio (2.11.3)
+    mysql2 (0.5.3)
+    nio4r (2.5.7)
+    passenger (6.0.8)
+      rack
+      rake (>= 0.8.1)
+    pg (1.2.3)
+    puma (5.2.2)
+      nio4r (~> 2.0)
+    rack (2.2.3)
+    raindrops (0.19.1)
+    rake (13.0.3)
+    roda (3.43.1)
+      rack
+    sequel (5.44.0)
+    sequel_pg (1.14.0)
+      pg (>= 0.18.0, != 1.2.0)
+      sequel (>= 4.38.0)
+    tilt (2.0.10)
+    unicorn (6.0.0)
+      kgio (~> 2.6)
+      raindrops (~> 0.7)
+
+PLATFORMS
+  x86_64-linux
+
+DEPENDENCIES
+  erubi (~> 1.10)
+  json (~> 2.5)
+  mysql2 (~> 0.5)
+  passenger (~> 6.0)
+  pg (~> 1.2)
+  puma (~> 5.2)
+  roda (~> 3.43)
+  sequel (~> 5.44)
+  sequel_pg (~> 1.14)
+  tilt (~> 2.0)
+  unicorn (~> 6.0)
+
+BUNDLED WITH
+   2.2.16

+ 0 - 44
frameworks/Ruby/roda-sequel/benchmark_config.json

@@ -133,50 +133,6 @@
         "display_name": "roda-sequel-postgres-unicorn-mri",
         "display_name": "roda-sequel-postgres-unicorn-mri",
         "versus": "rack-sequel-postgres-unicorn-mri",
         "versus": "rack-sequel-postgres-unicorn-mri",
         "notes": ""
         "notes": ""
-      },
-      "torquebox-jruby": {
-        "json_url": "/json",
-        "db_url": "/db",
-        "query_url": "/queries?queries=",
-        "fortune_url": "/fortunes",
-        "update_url": "/updates?queries=",
-        "plaintext_url": "/plaintext",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Micro",
-        "database": "MySQL",
-        "framework": "roda-sequel",
-        "language": "Ruby",
-        "orm": "Full",
-        "platform": "Rack",
-        "webserver": "TorqueBox",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "roda-sequel-torquebox-jruby",
-        "versus": "rack-sequel-torquebox-jruby",
-        "notes": ""
-      },
-      "postgres-torquebox-jruby": {
-        "json_url": "/json",
-        "db_url": "/db",
-        "query_url": "/queries?queries=",
-        "fortune_url": "/fortunes",
-        "update_url": "/updates?queries=",
-        "plaintext_url": "/plaintext",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Micro",
-        "database": "Postgres",
-        "framework": "roda-sequel",
-        "language": "Ruby",
-        "orm": "Full",
-        "platform": "Rack",
-        "webserver": "TorqueBox",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "roda-sequel-postgres-torquebox-jruby",
-        "versus": "rack-sequel-postgres-torquebox-jruby",
-        "notes": ""
       }
       }
     }
     }
   ]
   ]

+ 29 - 23
frameworks/Ruby/roda-sequel/hello_world.rb

@@ -2,57 +2,61 @@
 
 
 # Our Rack application to be executed by rackup
 # Our Rack application to be executed by rackup
 class HelloWorld < Roda
 class HelloWorld < Roda
-  plugin :default_headers, 'Content-Type'=>'text/html; charset=utf-8'
-  plugin :default_headers, 'Server'=>SERVER_STRING if SERVER_STRING
   plugin :hooks
   plugin :hooks
-  plugin :json
-  plugin :render, :escape=>true, :layout_opts=>{ :cache_key=>'default_layout' }
+  plugin :render, escape: true, layout_opts: { cache_key: 'default_layout' }
   plugin :static_routing
   plugin :static_routing
 
 
   def bounded_queries
   def bounded_queries
     queries = request['queries'].to_i
     queries = request['queries'].to_i
     return QUERIES_MIN if queries < QUERIES_MIN
     return QUERIES_MIN if queries < QUERIES_MIN
     return QUERIES_MAX if queries > QUERIES_MAX
     return QUERIES_MAX if queries > QUERIES_MAX
+
     queries
     queries
   end
   end
 
 
   # Return a random number between 1 and MAX_PK
   # Return a random number between 1 and MAX_PK
   def rand1
   def rand1
-    rand(MAX_PK).succ
+    rand(MAX_PK) + 1
   end
   end
 
 
   after do
   after do
     response['Date'] = Time.now.httpdate
     response['Date'] = Time.now.httpdate
+    response['Server'] = SERVER_STRING if SERVER_STRING
   end
   end
 
 
   # Test type 1: JSON serialization
   # Test type 1: JSON serialization
   static_get '/json' do |_|
   static_get '/json' do |_|
-    { :message=>'Hello, World!' }
+    response['Content-Type'] = 'application/json'
+
+    { message: 'Hello, World!' }.to_json
   end
   end
 
 
   # Test type 2: Single database query
   # Test type 2: Single database query
   static_get '/db' do |_|
   static_get '/db' do |_|
-    World.with_pk(rand1).values
+    response['Content-Type'] = 'application/json'
+
+    World.with_pk(rand1).values.to_json
   end
   end
 
 
   # Test type 3: Multiple database queries
   # Test type 3: Multiple database queries
   static_get '/queries' do |_|
   static_get '/queries' do |_|
-    worlds =
-      DB.synchronize do
-        Array.new(bounded_queries) do
-          World.with_pk(rand1)
-        end
+    response['Content-Type'] = 'application/json'
+    worlds = DB.synchronize do
+      Array.new(bounded_queries) do
+        World.with_pk(rand1).values
       end
       end
+    end
 
 
-    worlds.map!(&:values)
+    worlds.to_json
   end
   end
 
 
   # Test type 4: Fortunes
   # Test type 4: Fortunes
   static_get '/fortunes' do |_|
   static_get '/fortunes' do |_|
+    response['Content-Type'] = 'text/html; charset=utf-8'
     @fortunes = Fortune.all
     @fortunes = Fortune.all
     @fortunes << Fortune.new(
     @fortunes << Fortune.new(
-      :id=>0,
-      :message=>'Additional fortune added at request time.'
+      id: 0,
+      message: 'Additional fortune added at request time.'
     )
     )
     @fortunes.sort_by!(&:message)
     @fortunes.sort_by!(&:message)
 
 
@@ -61,16 +65,18 @@ class HelloWorld < Roda
 
 
   # Test type 5: Database updates
   # Test type 5: Database updates
   static_get '/updates' do |_|
   static_get '/updates' do |_|
-    worlds =
-      DB.synchronize do
-        Array.new(bounded_queries) do
-          world = World.with_pk(rand1)
-          world.update(:randomnumber=>rand1)
-          world
-        end
+    response['Content-Type'] = 'application/json'
+    worlds = DB.synchronize do
+      Array.new(bounded_queries) do
+        world = World.with_pk(rand1)
+        new_value = rand1
+        new_value = rand1 while new_value == world.randomnumber
+        world.update(randomnumber: new_value)
+        world.values
       end
       end
+    end
 
 
-    worlds.map!(&:values)
+    worlds.to_json
   end
   end
 
 
   # Test type 6: Plaintext
   # Test type 6: Plaintext

+ 1 - 1
frameworks/Ruby/roda-sequel/roda-sequel-passenger-mri.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.7
 
 
 ADD ./ /roda-sequel
 ADD ./ /roda-sequel
 WORKDIR /roda-sequel
 WORKDIR /roda-sequel

+ 1 - 1
frameworks/Ruby/roda-sequel/roda-sequel-postgres-passenger-mri.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.7
 
 
 ADD ./ /roda-sequel
 ADD ./ /roda-sequel
 WORKDIR /roda-sequel
 WORKDIR /roda-sequel

+ 0 - 14
frameworks/Ruby/roda-sequel/roda-sequel-postgres-torquebox-jruby.dockerfile

@@ -1,14 +0,0 @@
-FROM jruby:9.1
-
-ADD ./ /roda-sequel
-WORKDIR /roda-sequel
-
-ENV THREAD_FACTOR=2
-
-RUN bundle install --jobs=4 --gemfile=/roda-sequel/Gemfile --path=/roda-sequel/roda-sequel/bundle
-
-ENV DBTYPE=postgresql
-
-EXPOSE 8080
-
-CMD export MAX_CONCURRENCY=$(( 2 * $(nproc) )) && bundle exec torquebox run --io-threads $(( MAX_CONCURRENCY / 2 )) --worker-threads $MAX_CONCURRENCY -b 0.0.0.0 -p 8080 -e production

+ 1 - 1
frameworks/Ruby/roda-sequel/roda-sequel-postgres-unicorn-mri.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.7
 
 
 ADD ./ /roda-sequel
 ADD ./ /roda-sequel
 WORKDIR /roda-sequel
 WORKDIR /roda-sequel

+ 1 - 1
frameworks/Ruby/roda-sequel/roda-sequel-postgres.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.7
 
 
 ADD ./ /roda-sequel
 ADD ./ /roda-sequel
 WORKDIR /roda-sequel
 WORKDIR /roda-sequel

+ 0 - 14
frameworks/Ruby/roda-sequel/roda-sequel-torquebox-jruby.dockerfile

@@ -1,14 +0,0 @@
-FROM jruby:9.1
-
-ADD ./ /roda-sequel
-WORKDIR /roda-sequel
-
-ENV THREAD_FACTOR=2
-
-RUN bundle install --jobs=4 --gemfile=/roda-sequel/Gemfile --path=/roda-sequel/roda-sequel/bundle
-
-ENV DBTYPE=mysql
-
-EXPOSE 8080
-
-CMD export MAX_CONCURRENCY=$(( 2 * $(nproc) )) && bundle exec torquebox run --io-threads $(( MAX_CONCURRENCY / 2 )) --worker-threads $MAX_CONCURRENCY -b 0.0.0.0 -p 8080 -e production

+ 1 - 1
frameworks/Ruby/roda-sequel/roda-sequel-unicorn-mri.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.7
 
 
 ADD ./ /roda-sequel
 ADD ./ /roda-sequel
 WORKDIR /roda-sequel
 WORKDIR /roda-sequel

+ 1 - 1
frameworks/Ruby/roda-sequel/roda-sequel.dockerfile

@@ -1,4 +1,4 @@
-FROM ruby:2.4
+FROM ruby:2.7
 
 
 ADD ./ /roda-sequel
 ADD ./ /roda-sequel
 WORKDIR /roda-sequel
 WORKDIR /roda-sequel