-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
54 lines (44 loc) · 1.29 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'sinatra'
require 'sinatra/json'
require 'sidekiq'
require 'sidekiq-status'
require File.expand_path '../workers/ping_worker.rb', __FILE__
configure do
Sidekiq.configure_client do |config|
config.redis = { url: ENV["REDISTOGO_URL"] || "redis://localhost:6379/" }
config.client_middleware do |chain|
chain.add Sidekiq::Status::ClientMiddleware
end
end
Sidekiq.configure_server do |config|
config.redis = { url: ENV["REDISTOGO_URL"] || "redis://localhost:6379/" }
config.server_middleware do |chain|
chain.add Sidekiq::Status::ServerMiddleware, expiration: 30*60 # default
end
config.client_middleware do |chain|
chain.add Sidekiq::Status::ClientMiddleware
end
end
require "./lib/adapters/adapter"
Dir["./lib/adapters/*/*.rb"].each do |file|
require file
end
end
get '/' do
"hello world"
end
post '/petitions/:agency' do |agency|
job_id = PingWorker.perform_async({
user: params[:message],
petition: params[:petition]})
job_status = Sidekiq::Status::status(job_id)
json job: job_id, status: job_status
end
get '/agencies' do
json Bazooka::Adapter.registered.map {|id, adapter|
[id, adapter.full_name]
}.to_h
end
get '/agencies/:agency' do |agency|
json Bazooka::Adapter.registered[agency].dependencies
end