Skip to content

Commit

Permalink
fix: nicer locks
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Apr 27, 2011
1 parent 97236ef commit 4ea90de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/jobs/post_message.rb
Expand Up @@ -7,9 +7,13 @@ class PostMessage < Jobs::Base

extend Resque::Plugins::Lock

def self.lock(indexes)
"post-message:#{indexes.join('-')}"
end

def initialize(indexes)
@topic = Topic.where(:index => indexes.first).first
@message = @topic.find_message_by_indexes(message_indexes)
@message = @topic.find_message_by_indexes(indexes)
end

def perform!
Expand Down Expand Up @@ -46,7 +50,7 @@ def build_from
protected

def servers
@server ||= Group.where(:name => @topic.groups.first).map(&:servers).uniq
@server ||= Group.where(:name => @topic.groups.first).map(&:servers).flatten.uniq
end

end
Expand Down
4 changes: 4 additions & 0 deletions lib/jobs/update_group.rb
Expand Up @@ -9,6 +9,10 @@ class UpdateGroup < Jobs::Base

extend Resque::Plugins::Lock

def self.lock(group_name)
"update-group:#{group_name}"
end

def initialize(group_name)
@group_name = group_name
end
Expand Down

0 comments on commit 4ea90de

Please sign in to comment.