Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
Remove unnecessary references to options
Browse files Browse the repository at this point in the history
The options passed in are just the `global_uid_options`, refer to them
directly to make the code easier to follow.
  • Loading branch information
mriddle committed Apr 2, 2020
1 parent 613a19b commit 70b1957
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/global_uid/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ def self.new_connection(name, connection_timeout)

def self.init_server_info(options)
id_servers = self.global_uid_servers
increment_by = self.global_uid_options[:increment_by]

raise "You haven't configured any id servers" if id_servers.nil? or id_servers.empty?
raise "More servers configured than increment_by: #{id_servers.size} > #{options[:increment_by]} -- this will create duplicate IDs." if id_servers.size > options[:increment_by]
raise "More servers configured than increment_by: #{id_servers.size} > #{increment_by} -- this will create duplicate IDs." if id_servers.size > increment_by

id_servers.map do |name, i|
info = {}
Expand Down Expand Up @@ -109,7 +110,7 @@ def self.setup_connections!(options)

connection = new_connection(info[:name], connection_timeout)
info[:cx] = connection
info[:retry_at] = Time.now + options[:connection_retry] if connection.nil?
info[:retry_at] = Time.now + self.global_uid_options[:connection_retry] if connection.nil?
end
end

Expand All @@ -120,7 +121,7 @@ def self.with_connections(options = {})
options = self.global_uid_options.merge(options)
servers = setup_connections!(options)

if !options[:per_process_affinity]
if !self.global_uid_options[:per_process_affinity]
servers = servers.sort_by { rand } #yes, I know it's not true random.
end

Expand Down

0 comments on commit 70b1957

Please sign in to comment.