Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding with_master and release_master! helpers. #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's something here about if it was stuck to master before you ran this block.
Imagine if you were already stuck to master in a request, then called with_master - at the end of the block, I would think you'd recover the previous context (stuck to master).
I can imagine this is why there was an instance variable used in without_sticking and then leveraged in the various methods.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, ill update.

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