-
Notifications
You must be signed in to change notification settings - Fork 251
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
Allow registrations to be manifested on the file system and add 'use_previous_backends' option #115
Closed
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d5d061a
Add 'use_previous_backends' option.
jnb b855bff
Merge pull request #1 from jnb/use_previous_backends
jolynch 35f1f8f
Allow registrations to be manifested on the file system
jolynch c3d862c
Merge pull request #2 from jolynch/add_flat_file_output
jolynch 01826a0
Merge remote-tracking branch 'upstream/master'
jolynch 1fdd57e
Explicitly deduplicate registrations
jolynch 6eb5850
Allow the option allredisp option to haproxy.
jolynch e5411b0
Merge pull request #5 from jolynch/allow_allredisp_option
jnb c6c37fa
Merge pull request #4 from jolynch/dedup_ignore_ids
jolynch 136d1fe
Add rate limiter.
jnb e057dbf
Merge pull request #8 from Yelp/rate_limiter
jnb e6d03c2
Revert "Add rate limiter."
jnb a3e84d2
Increase HAProxy restart interval.
jnb d0c1161
Merge pull request #9 from Yelp/restart_interval
jolynch 5928c2b
ZooKeeper connection pooling.
jnb e96b2a9
Merge pull request #11 from Yelp/zk_pool
jolynch 4eab7e0
Rate limit restarts but not stats socket updates
jolynch 7de6a59
Merge pull request #10 from jolynch/jlynch_separate_stats_from_restart
jnb 030ccfe
Add state file.
jnb 235fa85
Merge pull request #12 from Yelp/state_file
jnb 36f2a94
Fix bug in caching logic.
jnb e90cf85
Merge pull request #13 from Yelp/fix_cache
jolynch 86d7f9d
Add support for the weight key added in nerve
bobtfish e49afdf
Merge pull request #14 from bobtfish/add_weight
jolynch a6a48e3
Try out :per_callback threads and get more debug information
jolynch 29f3197
Merge pull request #15 from jolynch/work_on_watcher_slowness
jnb 420440f
Turns out it's important to handle session disconnects correctly
429a20a
Merge pull request #16 from jolynch/fix_zk_session_bug
jnb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,56 @@ | ||
require 'synapse/log' | ||
require 'fileutils' | ||
require 'tempfile' | ||
|
||
module Synapse | ||
class FileOutput | ||
include Logging | ||
attr_reader :opts, :name | ||
|
||
def initialize(opts) | ||
super() | ||
|
||
unless opts.has_key?("output_directory") | ||
raise ArgumentError, "flat file generation requires an output_directory key" | ||
end | ||
|
||
begin | ||
FileUtils.mkdir_p(opts['output_directory']) | ||
rescue SystemCallError => err | ||
raise ArgumentError, "provided output directory #{opts['output_directory']} is not present or creatable" | ||
end | ||
|
||
@opts = opts | ||
@name = 'file_output' | ||
end | ||
|
||
def tick(watchers) | ||
end | ||
|
||
def update_config(watchers) | ||
watchers.each do |watcher| | ||
write_backends_to_file(watcher.name, watcher.backends) | ||
end | ||
end | ||
|
||
def write_backends_to_file(service_name, new_backends) | ||
data_path = File.join(@opts['output_directory'], "#{service_name}.json") | ||
begin | ||
old_backends = JSON.load(File.read(data_path)) | ||
rescue Errno::ENOENT | ||
old_backends = nil | ||
end | ||
|
||
if old_backends == new_backends | ||
return false | ||
else | ||
# Atomically write new sevice configuration file | ||
temp_path = File.join(@opts['output_directory'], | ||
".#{service_name}.json.tmp") | ||
File.open(temp_path, 'w', 0644) {|f| f.write(new_backends.to_json)} | ||
FileUtils.mv(temp_path, data_path) | ||
return true | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what this is calling out to, this class does not inherit from anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does not, I'll fix that up