Permalink
Browse files

expeditor

  • Loading branch information...
sorah committed Oct 31, 2015
1 parent 82333ec commit d68baebb1837c87a6552a75b7d4748ea0b3d4aa3
Showing with 21 additions and 6 deletions.
  1. +2 −0 5f/webapp/ruby/Gemfile
  2. +11 −0 5f/webapp/ruby/Gemfile.lock
  3. +8 −6 5f/webapp/ruby/app.rb
View
@@ -10,3 +10,5 @@ gem "httpclient"
gem 'redis'
gem 'stackprof'
+
+gem 'expeditor'
@@ -2,7 +2,15 @@ GEM
remote: https://rubygems.org/
specs:
backports (3.6.6)
+ concurrent-ruby (0.8.0)
+ ref (~> 1.0, >= 1.0.5)
+ concurrent-ruby-ext (0.8.0)
+ concurrent-ruby (~> 0.8.0)
erubis (2.7.0)
+ expeditor (0.1.1)
+ concurrent-ruby (= 0.8.0)
+ concurrent-ruby-ext (= 0.8.0)
+ retryable (> 1.0)
httpclient (2.6.0.1)
kgio (2.10.0)
multi_json (1.11.2)
@@ -14,6 +22,8 @@ GEM
rack (>= 1.0)
raindrops (0.15.0)
redis (3.2.1)
+ ref (1.0.5)
+ retryable (2.0.1)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
@@ -37,6 +47,7 @@ PLATFORMS
DEPENDENCIES
erubis
+ expeditor
httpclient
pg
redis
View
@@ -6,6 +6,7 @@
require 'json'
require 'httpclient'
require 'openssl'
+require 'expeditor'
# bundle config build.pg --with-pg-config=<path to pg_config>
# bundle install
@@ -255,14 +256,15 @@ def fetch_api(method, uri, headers, params)
arg_json = db.exec_params("SELECT arg FROM subscriptions WHERE user_id=$1", [user[:id]]).values.first[0]
arg = JSON.parse(arg_json)
- data = []
-
- arg.each_pair do |service, conf|
- endpoint = Isucon5f::Endpoint.get(service)
- data << {"service" => service, "data" => endpoint.fetch(conf)}
+ data = arg.map do |service, conf|
+ Expeditor::Command.new do
+ endpoint = Isucon5f::Endpoint.get(service)
+ {"service" => service, "data" => endpoint.fetch(conf)}
+ end
end
- json data
+ data.each(&:start)
+ json data.map(&:get)
end
get '/initialize' do

0 comments on commit d68baeb

Please sign in to comment.