Skip to content

Commit

Permalink
Merge pull request #9 from wallarm/develop
Browse files Browse the repository at this point in the history
Fix lua code for redis >= 6.2.7
  • Loading branch information
yamax2 authored Apr 28, 2022
2 parents bf06f40 + 5d99e1d commit 6c43d44
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["2.7", "3", "3.1"]
redis-version: ["5", "6"]
ruby-version: ["2.7", "3.0", "3.1"]
redis-version: ["5", "6", "7"]

services:
redis:
Expand Down
12 changes: 9 additions & 3 deletions dip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@ version: "5.0"

compose:
files:
- ./docker-compose.yml
- docker/docker-compose.yml
project_name: qless

interaction:
ruby:
service: ruby
command: /bin/bash
command: sh

sh:
service: ruby
command: /bin/bash
command: sh

bundle:
service: ruby
command: bundle

clean:
service: ruby
command: rm -f Gemfile.lock

rspec:
service: ruby
command: bundle exec rspec

provision:
- docker volume create --name bundler_data
- dip clean
- dip bundle install
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ruby:3.1-alpine

RUN gem update --system && \
apk add --update --no-cache less git build-base curl jq mc

WORKDIR /app
14 changes: 8 additions & 6 deletions docker-compose.yml → docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
version: "2.1"
version: "3.7"
services:
ruby:
image: ruby:2.7
build:
context: ../
dockerfile: ./docker/Dockerfile
depends_on:
- redis
environment:
- BUNDLE_PATH=/bundle/2.7
- BUNDLE_PATH=/bundle/3.1
- RACK_ENV=test
- REDIS_HOST=redis
- SKIP_JS_SPEC=true
volumes:
- .:/usr/src/qless
- ..:/app
- bundler-data:/bundle
working_dir: /usr/src/qless

redis:
image: redis:6
image: redis:7-alpine

volumes:
bundler-data:
Expand Down
6 changes: 3 additions & 3 deletions lib/qless/lua/qless-lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ QlessRecurringJob.__index = QlessRecurringJob
Qless.config = {}

-- Extend a table. This comes up quite frequently
function table.extend(self, other)
local function table_extend(self, other)
for i, v in ipairs(other) do
table.insert(self, v)
end
Expand Down Expand Up @@ -1525,7 +1525,7 @@ function QlessQueue:peek(now, count)

-- With these in place, we can expand this list of jids based on the work
-- queue itself and the priorities therein
table.extend(jids, self.work.peek(count - #jids))
table_extend(jids, self.work.peek(count - #jids))

return jids
end
Expand Down Expand Up @@ -1600,7 +1600,7 @@ function QlessQueue:pop(now, worker, count)

-- With these in place, we can expand this list of jids based on the work
-- queue itself and the priorities therein
table.extend(jids, self.work.peek(count - #jids))
table_extend(jids, self.work.peek(count - #jids))

local state
for index, jid in ipairs(jids) do
Expand Down
6 changes: 3 additions & 3 deletions lib/qless/lua/qless.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ QlessRecurringJob.__index = QlessRecurringJob

Qless.config = {}

function table.extend(self, other)
local function table_extend(self, other)
for i, v in ipairs(other) do
table.insert(self, v)
end
Expand Down Expand Up @@ -1121,7 +1121,7 @@ function QlessQueue:peek(now, count)

self:check_scheduled(now, count - #jids)

table.extend(jids, self.work.peek(count - #jids))
table_extend(jids, self.work.peek(count - #jids))

return jids
end
Expand Down Expand Up @@ -1170,7 +1170,7 @@ function QlessQueue:pop(now, worker, count)

self:check_scheduled(now, count - #jids)

table.extend(jids, self.work.peek(count - #jids))
table_extend(jids, self.work.peek(count - #jids))

local state
for index, jid in ipairs(jids) do
Expand Down

0 comments on commit 6c43d44

Please sign in to comment.