Class: Headsail::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/headsail/task.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Task

Returns a new instance of Task.



8
9
10
11
12
13
# File 'lib/headsail/task.rb', line 8

def initialize(config)
  @api = API.new(config)
  @redis = Redis.new(@api.name)
  @http = HTTP.new(@api)
  Headsail.info("API Task '#{@api.name}' added.")
end

Instance Method Details

#runObject



15
16
17
18
19
20
# File 'lib/headsail/task.rb', line 15

def run
  Concurrent::TimerTask.new(execution_interval: @api.timer) do
    @redis.add(@http.body) if @http.run
    request_message
  end
end