fairway 0.3.2 → 0.3.4
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 +8 -8
- data/Gemfile.lock +1 -1
- data/go/fairway_ack.go +5 -4
- data/go/fairway_deliver.go +8 -8
- data/go/fairway_pull.go +5 -5
- data/go/queue_test.go +9 -9
- data/lib/fairway/version.rb +1 -1
- data/redis/fairway_deliver.lua +8 -8
- data/redis/fairway_pull.lua +5 -6
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            !binary "U0hBMQ==":
         | 
| 3 3 | 
             
              metadata.gz: !binary |-
         | 
| 4 | 
            -
                 | 
| 4 | 
            +
                ZTYxMDc5ZDNmZWM4YmViYmExMzZlZTEyYTJhMmQ5ZTZkYzA5MGM2OQ==
         | 
| 5 5 | 
             
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                ZjZhOTMyYTI0OTgzOTU3OTlmMTFhZDkyNzU4Y2U0NjVmOGQ4Yjc4NQ==
         | 
| 7 7 | 
             
            SHA512:
         | 
| 8 8 | 
             
              metadata.gz: !binary |-
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 9 | 
            +
                YmNlOTE3ODUzNmVmYWIwM2QwODUzN2NlMzM1NjAxMGQxMDk2ODY2NWE2Nzg5
         | 
| 10 | 
            +
                ZjUyNTcwNzI5NmQxNjgxNzI5MDhjMDVhZDUxNDE3ODFiODZhZGFmZmRkNzYw
         | 
| 11 | 
            +
                Njg0YjU3MjI5MDIxZTg4M2I4ZGE5ZGU5MmMwNWU0MGQyMmM4YzU=
         | 
| 12 12 | 
             
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                 | 
| 15 | 
            -
                 | 
| 13 | 
            +
                NzhjMGQwMjg0YzIzYzcxMzJmODhkYTJkYmFkZmM0ZWM2NmQzN2ZmZmQxOWQw
         | 
| 14 | 
            +
                NGE2YTJhNjJiMjg0NGZiOWE4MjhiYTdjNmZjZDYxZTY0YzljOWY1M2NiNTc2
         | 
| 15 | 
            +
                NGM0ODQxNGJkNmM4YmVkYzFiMDNlNWM1ZmRjM2Y3NjM5ZDBkOTU=
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/go/fairway_ack.go
    CHANGED
    
    | @@ -17,18 +17,19 @@ local round_robin    = k(queue, 'facet_queue'); | |
| 17 17 | 
             
            local facet_pool     = k(queue, 'facet_pool');
         | 
| 18 18 | 
             
            local inflight       = k(queue, 'inflight');
         | 
| 19 19 | 
             
            local messages       = k(queue, facet);
         | 
| 20 | 
            -
            local  | 
| 20 | 
            +
            local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 21 21 | 
             
            local inflight_limit = k(queue, 'limit');
         | 
| 22 22 | 
             
            local priorities     = k(queue, 'priorities');
         | 
| 23 23 |  | 
| 24 | 
            -
            local removed = tonumber(redis.call('zrem', inflight, message))
         | 
| 24 | 
            +
            local removed = tonumber(redis.call('zrem', inflight, message));
         | 
| 25 | 
            +
            redis.call('srem', inflight_facet, message);
         | 
| 25 26 |  | 
| 26 27 | 
             
            if removed > 0 then
         | 
| 27 28 | 
             
              -- Manage facet queue and active facets
         | 
| 28 29 | 
             
              local current       = tonumber(redis.call('hget', facet_pool, facet)) or 0;
         | 
| 29 30 | 
             
              local priority      = tonumber(redis.call('hget', priorities, facet)) or 1;
         | 
| 30 31 | 
             
              local length        = redis.call('llen', messages);
         | 
| 31 | 
            -
              local inflight_cur  = tonumber(redis.call(' | 
| 32 | 
            +
              local inflight_cur  = tonumber(redis.call('scard', inflight_facet)) or 0;
         | 
| 32 33 | 
             
              local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 33 34 |  | 
| 34 35 | 
             
              local n = 0
         | 
| @@ -50,7 +51,7 @@ if removed > 0 then | |
| 50 51 | 
             
              end
         | 
| 51 52 |  | 
| 52 53 | 
             
              if (length == 0 and inflight_cur == 0 and n == 0) then
         | 
| 53 | 
            -
                redis.call('del',  | 
| 54 | 
            +
                redis.call('del', inflight_facet);
         | 
| 54 55 | 
             
                redis.call('hdel', facet_pool, facet);
         | 
| 55 56 | 
             
                redis.call('srem', active_facets, facet);
         | 
| 56 57 | 
             
              end
         | 
    
        data/go/fairway_deliver.go
    CHANGED
    
    | @@ -27,8 +27,8 @@ for i = 1, #registered_queues, 2 do | |
| 27 27 | 
             
                local active_facets  = k(queue, 'active_facets');
         | 
| 28 28 | 
             
                local round_robin    = k(queue, 'facet_queue');
         | 
| 29 29 | 
             
                local facet_pool     = k(queue, 'facet_pool');
         | 
| 30 | 
            -
                local  | 
| 31 | 
            -
                local inflight_limit = k(queue, 'limit');
         | 
| 30 | 
            +
                -- local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 31 | 
            +
                -- local inflight_limit = k(queue, 'limit');
         | 
| 32 32 |  | 
| 33 33 | 
             
                -- Delivering the message to a queue is as simple as
         | 
| 34 34 | 
             
                -- pushing it onto the facet's message list, and
         | 
| @@ -39,18 +39,18 @@ for i = 1, #registered_queues, 2 do | |
| 39 39 | 
             
                -- Manage facet queue and active facets
         | 
| 40 40 | 
             
                local current       = tonumber(redis.call('hget', facet_pool, facet)) or 0;
         | 
| 41 41 | 
             
                local priority      = tonumber(redis.call('hget', priorities, facet)) or 1;
         | 
| 42 | 
            -
                local inflight_cur  = tonumber(redis.call(' | 
| 43 | 
            -
                local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 42 | 
            +
                -- local inflight_cur  = tonumber(redis.call('scard', inflight_facet)) or 0;
         | 
| 43 | 
            +
                -- local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 44 44 |  | 
| 45 45 | 
             
                local n = 0
         | 
| 46 46 |  | 
| 47 47 | 
             
                -- redis.log(redis.LOG_WARNING, current.."/"..length.."/"..priority.."/"..inflight_max.."/"..inflight_cur);
         | 
| 48 48 |  | 
| 49 | 
            -
                if inflight_max > 0 then
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                else
         | 
| 49 | 
            +
                -- if inflight_max > 0 then
         | 
| 50 | 
            +
                --   n = math.min(length, priority, inflight_max - inflight_cur);
         | 
| 51 | 
            +
                -- else
         | 
| 52 52 | 
             
                  n = math.min(length, priority);
         | 
| 53 | 
            -
                end
         | 
| 53 | 
            +
                -- end
         | 
| 54 54 |  | 
| 55 55 | 
             
                -- redis.log(redis.LOG_WARNING, "PUSH: "..current.."/"..n);
         | 
| 56 56 |  | 
    
        data/go/fairway_pull.go
    CHANGED
    
    | @@ -25,14 +25,14 @@ local pull = function (queue) | |
| 25 25 | 
             
                -- has at least one message available to be pulled
         | 
| 26 26 | 
             
                -- from it's message queue.
         | 
| 27 27 | 
             
                local messages       = k(queue, facet);
         | 
| 28 | 
            -
                local  | 
| 28 | 
            +
                local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 29 29 |  | 
| 30 30 | 
             
                message = redis.call('rpop', messages);
         | 
| 31 31 |  | 
| 32 32 | 
             
                if message then
         | 
| 33 33 | 
             
                  if wait ~= -1 then
         | 
| 34 34 | 
             
                    redis.call('zadd', inflight, timestamp + wait, message);
         | 
| 35 | 
            -
                    redis.call(' | 
| 35 | 
            +
                    redis.call('sadd', inflight_facet, message);
         | 
| 36 36 | 
             
                  end
         | 
| 37 37 |  | 
| 38 38 | 
             
                  redis.call('decr', k(queue, 'length'));
         | 
| @@ -49,12 +49,12 @@ local manage = function (queue, facet) | |
| 49 49 | 
             
              local priorities     = k(queue, 'priorities');
         | 
| 50 50 | 
             
              local facet_pool     = k(queue, 'facet_pool');
         | 
| 51 51 | 
             
              local messages       = k(queue, facet);
         | 
| 52 | 
            -
              local  | 
| 52 | 
            +
              local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 53 53 |  | 
| 54 54 | 
             
              local current       = tonumber(redis.call('hget', facet_pool, facet)) or 0;
         | 
| 55 55 | 
             
              local priority      = tonumber(redis.call('hget', priorities, facet)) or 1;
         | 
| 56 56 | 
             
              local length        = redis.call('llen', messages);
         | 
| 57 | 
            -
              local inflight_cur  = tonumber(redis.call(' | 
| 57 | 
            +
              local inflight_cur  = tonumber(redis.call('scard', inflight_facet)) or 0;
         | 
| 58 58 | 
             
              local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 59 59 |  | 
| 60 60 | 
             
              local n = 0
         | 
| @@ -83,7 +83,7 @@ local manage = function (queue, facet) | |
| 83 83 | 
             
              end
         | 
| 84 84 |  | 
| 85 85 | 
             
              if (length == 0 and inflight_cur == 0 and n == 0) then
         | 
| 86 | 
            -
                redis.call('del',  | 
| 86 | 
            +
                redis.call('del', inflight_facet);
         | 
| 87 87 | 
             
                redis.call('hdel', facet_pool, facet);
         | 
| 88 88 | 
             
                redis.call('srem', active_facets, facet);
         | 
| 89 89 | 
             
              end
         | 
    
        data/go/queue_test.go
    CHANGED
    
    | @@ -244,16 +244,16 @@ func QueueSpec(c gospec.Context) { | |
| 244 244 | 
             
            			_, message := queue.Pull(2)
         | 
| 245 245 | 
             
            			c.Expect(message.json(), Equals, msg1.json())
         | 
| 246 246 |  | 
| 247 | 
            -
            			count, _ := redis.Int(r.Do(" | 
| 247 | 
            +
            			count, _ := redis.Int(r.Do("scard", "fairway:myqueue:1:inflight"))
         | 
| 248 248 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 249 249 |  | 
| 250 250 | 
             
            			_, message = queue.Pull(2)
         | 
| 251 251 | 
             
            			c.Expect(message.json(), Equals, msg3.json())
         | 
| 252 252 |  | 
| 253 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 253 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:1:inflight"))
         | 
| 254 254 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 255 255 |  | 
| 256 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 256 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:2:inflight"))
         | 
| 257 257 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 258 258 |  | 
| 259 259 | 
             
            			_, message = queue.Pull(2)
         | 
| @@ -261,10 +261,10 @@ func QueueSpec(c gospec.Context) { | |
| 261 261 | 
             
            			_, message = queue.Pull(2)
         | 
| 262 262 | 
             
            			c.Expect(message, IsNil)
         | 
| 263 263 |  | 
| 264 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 264 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:1:inflight"))
         | 
| 265 265 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 266 266 |  | 
| 267 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 267 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:2:inflight"))
         | 
| 268 268 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 269 269 |  | 
| 270 270 | 
             
            			queue.Ack(msg1)
         | 
| @@ -273,20 +273,20 @@ func QueueSpec(c gospec.Context) { | |
| 273 273 | 
             
            			queue.Ack(msg1)
         | 
| 274 274 | 
             
            			queue.Ack(msg1)
         | 
| 275 275 |  | 
| 276 | 
            -
            			count, err := redis.Int(r.Do(" | 
| 276 | 
            +
            			count, err := redis.Int(r.Do("scard", "fairway:myqueue:1:inflight"))
         | 
| 277 277 | 
             
            			c.Expect(count, Equals, 0)
         | 
| 278 278 | 
             
            			c.Expect(err, IsNil)
         | 
| 279 279 |  | 
| 280 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 280 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:2:inflight"))
         | 
| 281 281 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 282 282 |  | 
| 283 283 | 
             
            			_, message = queue.Pull(2)
         | 
| 284 284 | 
             
            			c.Expect(message.json(), Equals, msg2.json())
         | 
| 285 285 |  | 
| 286 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 286 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:1:inflight"))
         | 
| 287 287 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 288 288 |  | 
| 289 | 
            -
            			count, _ = redis.Int(r.Do(" | 
| 289 | 
            +
            			count, _ = redis.Int(r.Do("scard", "fairway:myqueue:2:inflight"))
         | 
| 290 290 | 
             
            			c.Expect(count, Equals, 1)
         | 
| 291 291 | 
             
            		})
         | 
| 292 292 |  | 
    
        data/lib/fairway/version.rb
    CHANGED
    
    
    
        data/redis/fairway_deliver.lua
    CHANGED
    
    | @@ -23,8 +23,8 @@ for i = 1, #registered_queues, 2 do | |
| 23 23 | 
             
                local active_facets  = k(queue, 'active_facets');
         | 
| 24 24 | 
             
                local round_robin    = k(queue, 'facet_queue');
         | 
| 25 25 | 
             
                local facet_pool     = k(queue, 'facet_pool');
         | 
| 26 | 
            -
                local  | 
| 27 | 
            -
                local inflight_limit = k(queue, 'limit');
         | 
| 26 | 
            +
                -- local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 27 | 
            +
                -- local inflight_limit = k(queue, 'limit');
         | 
| 28 28 |  | 
| 29 29 | 
             
                -- Delivering the message to a queue is as simple as
         | 
| 30 30 | 
             
                -- pushing it onto the facet's message list, and
         | 
| @@ -35,18 +35,18 @@ for i = 1, #registered_queues, 2 do | |
| 35 35 | 
             
                -- Manage facet queue and active facets
         | 
| 36 36 | 
             
                local current       = tonumber(redis.call('hget', facet_pool, facet)) or 0;
         | 
| 37 37 | 
             
                local priority      = tonumber(redis.call('hget', priorities, facet)) or 1;
         | 
| 38 | 
            -
                local inflight_cur  = tonumber(redis.call(' | 
| 39 | 
            -
                local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 38 | 
            +
                -- local inflight_cur  = tonumber(redis.call('scard', inflight_facet)) or 0;
         | 
| 39 | 
            +
                -- local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 40 40 |  | 
| 41 41 | 
             
                local n = 0
         | 
| 42 42 |  | 
| 43 43 | 
             
                -- redis.log(redis.LOG_WARNING, current.."/"..length.."/"..priority.."/"..inflight_max.."/"..inflight_cur);
         | 
| 44 44 |  | 
| 45 | 
            -
                if inflight_max > 0 then
         | 
| 46 | 
            -
             | 
| 47 | 
            -
                else
         | 
| 45 | 
            +
                -- if inflight_max > 0 then
         | 
| 46 | 
            +
                --   n = math.min(length, priority, inflight_max - inflight_cur);
         | 
| 47 | 
            +
                -- else
         | 
| 48 48 | 
             
                  n = math.min(length, priority);
         | 
| 49 | 
            -
                end
         | 
| 49 | 
            +
                -- end
         | 
| 50 50 |  | 
| 51 51 | 
             
                -- redis.log(redis.LOG_WARNING, "PUSH: "..current.."/"..n);
         | 
| 52 52 |  | 
    
        data/redis/fairway_pull.lua
    CHANGED
    
    | @@ -21,14 +21,14 @@ local pull = function (queue) | |
| 21 21 | 
             
                -- has at least one message available to be pulled
         | 
| 22 22 | 
             
                -- from it's message queue.
         | 
| 23 23 | 
             
                local messages       = k(queue, facet);
         | 
| 24 | 
            -
                local  | 
| 24 | 
            +
                local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 25 25 |  | 
| 26 26 | 
             
                message = redis.call('rpop', messages);
         | 
| 27 27 |  | 
| 28 28 | 
             
                if message then
         | 
| 29 29 | 
             
                  if wait ~= -1 then
         | 
| 30 30 | 
             
                    redis.call('zadd', inflight, timestamp + wait, message);
         | 
| 31 | 
            -
                    redis.call(' | 
| 31 | 
            +
                    redis.call('sadd', inflight_facet, message);
         | 
| 32 32 | 
             
                  end
         | 
| 33 33 |  | 
| 34 34 | 
             
                  redis.call('decr', k(queue, 'length'));
         | 
| @@ -45,12 +45,12 @@ local manage = function (queue, facet) | |
| 45 45 | 
             
              local priorities     = k(queue, 'priorities');
         | 
| 46 46 | 
             
              local facet_pool     = k(queue, 'facet_pool');
         | 
| 47 47 | 
             
              local messages       = k(queue, facet);
         | 
| 48 | 
            -
              local  | 
| 48 | 
            +
              local inflight_facet = k(queue, facet .. ':inflight');
         | 
| 49 49 |  | 
| 50 50 | 
             
              local current       = tonumber(redis.call('hget', facet_pool, facet)) or 0;
         | 
| 51 51 | 
             
              local priority      = tonumber(redis.call('hget', priorities, facet)) or 1;
         | 
| 52 52 | 
             
              local length        = redis.call('llen', messages);
         | 
| 53 | 
            -
              local inflight_cur  = tonumber(redis.call(' | 
| 53 | 
            +
              local inflight_cur  = tonumber(redis.call('scard', inflight_facet)) or 0;
         | 
| 54 54 | 
             
              local inflight_max  = tonumber(redis.call('get', inflight_limit)) or 0;
         | 
| 55 55 |  | 
| 56 56 | 
             
              local n = 0
         | 
| @@ -79,7 +79,7 @@ local manage = function (queue, facet) | |
| 79 79 | 
             
              end
         | 
| 80 80 |  | 
| 81 81 | 
             
              if (length == 0 and inflight_cur == 0 and n == 0) then
         | 
| 82 | 
            -
                redis.call('del',  | 
| 82 | 
            +
                redis.call('del', inflight_facet);
         | 
| 83 83 | 
             
                redis.call('hdel', facet_pool, facet);
         | 
| 84 84 | 
             
                redis.call('srem', active_facets, facet);
         | 
| 85 85 | 
             
              end
         | 
| @@ -130,4 +130,3 @@ for i, queue in ipairs(ARGV) do | |
| 130 130 | 
             
                return {queue, message};
         | 
| 131 131 | 
             
              end
         | 
| 132 132 | 
             
            end
         | 
| 133 | 
            -
             | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fairway
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - John Allison
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-02- | 
| 11 | 
            +
            date: 2016-02-26 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |