From 70b19575e1de74643375654cdf9327b909120b73 Mon Sep 17 00:00:00 2001 From: Matthew Riddle Date: Thu, 2 Apr 2020 13:27:44 +0200 Subject: [PATCH] Remove unnecessary references to `options` The options passed in are just the `global_uid_options`, refer to them directly to make the code easier to follow. --- lib/global_uid/base.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/global_uid/base.rb b/lib/global_uid/base.rb index 64177cc..e755e67 100644 --- a/lib/global_uid/base.rb +++ b/lib/global_uid/base.rb @@ -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 = {} @@ -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 @@ -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