global_uid 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/global_uid/base.rb +14 -8
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f17fa1ca013a3522b17564a1a5221f6808fe5a13
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2768edccf2ce2c846149b346533ef1723e0f4cea
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2ad21dd9b622a6c67314474d14b8150293a9b8c54350090e91ed58abd17cbe847280c0b6992b28db3c496ba9373e2dcd90ac791e2eca69cc4672d42d986f93fa
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9b5e0e4f6a14f99c120cf5d1cd8cdab218bb886e260123fb3537c1dd8c47987a1287e1319c840f990d271e719fc302fa5a7b2c6ad83b683a6ef03d16d55bda8b
         
     | 
    
        data/lib/global_uid/base.rb
    CHANGED
    
    | 
         @@ -11,8 +11,6 @@ end 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            module GlobalUid
         
     | 
| 
       13 
13 
     | 
    
         
             
              class Base
         
     | 
| 
       14 
     | 
    
         
            -
                @@servers = nil
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
14 
     | 
    
         
             
                GLOBAL_UID_DEFAULTS = {
         
     | 
| 
       17 
15 
     | 
    
         
             
                  :connection_timeout   => 3,
         
     | 
| 
       18 
16 
     | 
    
         
             
                  :connection_retry     => 10.minutes,
         
     | 
| 
         @@ -24,6 +22,14 @@ module GlobalUid 
     | 
|
| 
       24 
22 
     | 
    
         
             
                  :dry_run              => false
         
     | 
| 
       25 
23 
     | 
    
         
             
                }
         
     | 
| 
       26 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
                def self.servers
         
     | 
| 
      
 26 
     | 
    
         
            +
                  Thread.current[:servers]
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def self.servers=(s)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Thread.current[:servers] = s
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       27 
33 
     | 
    
         
             
                def self.create_uid_tables(id_table_name, options={})
         
     | 
| 
       28 
34 
     | 
    
         
             
                  type     = options[:uid_type] || "bigint(21) UNSIGNED"
         
     | 
| 
       29 
35 
     | 
    
         
             
                  start_id = options[:start_id] || 1
         
     | 
| 
         @@ -106,20 +112,20 @@ module GlobalUid 
     | 
|
| 
       106 
112 
     | 
    
         
             
                end
         
     | 
| 
       107 
113 
     | 
    
         | 
| 
       108 
114 
     | 
    
         
             
                def self.disconnect!
         
     | 
| 
       109 
     | 
    
         
            -
                   
     | 
| 
      
 115 
     | 
    
         
            +
                  self.servers = nil
         
     | 
| 
       110 
116 
     | 
    
         
             
                end
         
     | 
| 
       111 
117 
     | 
    
         | 
| 
       112 
118 
     | 
    
         
             
                def self.setup_connections!(options)
         
     | 
| 
       113 
119 
     | 
    
         
             
                  connection_timeout = options[:connection_timeout]
         
     | 
| 
       114 
120 
     | 
    
         
             
                  increment_by       = options[:increment_by]
         
     | 
| 
       115 
121 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                  if  
     | 
| 
       117 
     | 
    
         
            -
                     
     | 
| 
      
 122 
     | 
    
         
            +
                  if self.servers.nil?
         
     | 
| 
      
 123 
     | 
    
         
            +
                    self.servers = init_server_info(options)
         
     | 
| 
       118 
124 
     | 
    
         
             
                    # sorting here sets up each process to have affinity to a particular server.
         
     | 
| 
       119 
     | 
    
         
            -
                     
     | 
| 
      
 125 
     | 
    
         
            +
                    self.servers = self.servers.sort_by { |s| s[:rand] }
         
     | 
| 
       120 
126 
     | 
    
         
             
                  end
         
     | 
| 
       121 
127 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                   
     | 
| 
      
 128 
     | 
    
         
            +
                  self.servers.each do |info|
         
     | 
| 
       123 
129 
     | 
    
         
             
                    next if info[:cx]
         
     | 
| 
       124 
130 
     | 
    
         | 
| 
       125 
131 
     | 
    
         
             
                    if info[:new?] || ( info[:retry_at] && Time.now > info[:retry_at] )
         
     | 
| 
         @@ -131,7 +137,7 @@ module GlobalUid 
     | 
|
| 
       131 
137 
     | 
    
         
             
                    end
         
     | 
| 
       132 
138 
     | 
    
         
             
                  end
         
     | 
| 
       133 
139 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
                   
     | 
| 
      
 140 
     | 
    
         
            +
                  self.servers
         
     | 
| 
       135 
141 
     | 
    
         
             
                end
         
     | 
| 
       136 
142 
     | 
    
         | 
| 
       137 
143 
     | 
    
         
             
                def self.with_connections(options = {})
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: global_uid
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ben Osheroff
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-10-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activerecord
         
     |