forked from huginn/huginn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into bump_weibo_2
- Loading branch information
Showing
8 changed files
with
63 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AgentCheckJob < ActiveJob::Base | ||
# Given an Agent id, load the Agent, call #check on it, and then save it with an updated `last_check_at` timestamp. | ||
def perform(agent_id) | ||
agent = Agent.find(agent_id) | ||
begin | ||
return if agent.unavailable? | ||
agent.check | ||
agent.last_check_at = Time.now | ||
agent.save! | ||
rescue => e | ||
agent.error "Exception during check. #{e.message}: #{e.backtrace.join("\n")}" | ||
raise | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class AgentReceiveJob < ActiveJob::Base | ||
# Given an Agent id and an array of Event ids, load the Agent, call #receive on it with the Event objects, and then | ||
# save it with an updated `last_receive_at` timestamp. | ||
def perform(agent_id, event_ids) | ||
agent = Agent.find(agent_id) | ||
begin | ||
return if agent.unavailable? | ||
agent.receive(Event.where(:id => event_ids).order(:id)) | ||
agent.last_receive_at = Time.now | ||
agent.save! | ||
rescue => e | ||
agent.error "Exception during receive. #{e.message}: #{e.backtrace.join("\n")}" | ||
raise | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters