-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathservice.rb
More file actions
54 lines (47 loc) · 1.18 KB
/
service.rb
File metadata and controls
54 lines (47 loc) · 1.18 KB
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
# frozen_string_literal: true
require 'faraday'
require 'json'
require 'travis/service/job_board'
module Travis
module Scheduler
def self.push(*args)
::Sidekiq::Client.push(
'queue' => ENV['SIDEKIQ_QUEUE'] || 'scheduler',
'class' => 'Travis::Scheduler::Worker',
'args' => args.map! { |arg| arg.to_json },
'at' => args.last.is_a?(Hash) ? (args.last.delete(:at) || Time.now.to_i) : Time.now.to_i
)
end
end
module Hub
def self.push(*args)
::Sidekiq::Client.push(
'queue' => 'hub',
'class' => 'Travis::Hub::Sidekiq::Worker',
'args' => args.map! { |arg| arg.to_json }
)
end
end
module Live
def self.push(*args)
::Sidekiq::Client.push(
'queue' => 'pusher-live',
'class' => 'Travis::Async::Sidekiq::Worker',
'args' => [nil, nil, nil, *args].map! { |arg| arg.to_json }
)
end
end
module JobBoard
class << self
def post(job_id, data)
Service::JobBoard.new(job_id, data, config, logger).post
end
def config
Scheduler.context.config
end
def logger
Scheduler.context.logger
end
end
end
end