Skip to content

Commit

Permalink
Adding with_master and release_master! helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster committed Oct 31, 2019
1 parent dac6be2 commit 01d2ada
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ spec/reports
test/tmp
test/version_tmp
tmp
.idea/
13 changes: 13 additions & 0 deletions lib/makara/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ def stick_to_master!(persist = true)
Makara::Context.stick(@id, stickiness_duration)
end

def with_master
stick_to_master!
yield if block_given?
ensure
release_master!
end

def release_master!
if stuck_to_master?
Makara::Context.release(@id)
end
end

def strategy_for(role)
strategy_class_for(strategy_name_for(role)).new(self)
end
Expand Down

0 comments on commit 01d2ada

Please sign in to comment.