Bump sidekiq, sidekiq-cron and migrate to redis-client

This breaks compatibility with redis <6
This commit is contained in:
Benjamin Neff
2023-06-26 01:40:46 +02:00
parent cc4d2e0832
commit a59505574a
6 changed files with 25 additions and 21 deletions

View File

@@ -42,12 +42,12 @@ gem "simple_captcha2", "0.5.0", require: "simple_captcha"
# Background processing # Background processing
gem "redis", "4.7.0" gem "redis-client", "0.14.1"
gem "sidekiq", "6.5.1" gem "sidekiq", "7.1.2"
# Scheduled processing # Scheduled processing
gem "sidekiq-cron", "1.6.0" gem "sidekiq-cron", "1.10.1"
# Compression # Compression

View File

@@ -143,7 +143,7 @@ GEM
coderay (1.1.3) coderay (1.1.3)
concurrent-ruby (1.2.2) concurrent-ruby (1.2.2)
configurate (0.5.0) configurate (0.5.0)
connection_pool (2.2.5) connection_pool (2.4.1)
crack (0.4.5) crack (0.4.5)
rexml rexml
crass (1.0.6) crass (1.0.6)
@@ -311,7 +311,7 @@ GEM
fog-core fog-core
nokogiri (>= 1.5.11, < 2.0.0) nokogiri (>= 1.5.11, < 2.0.0)
formatador (1.1.0) formatador (1.1.0)
fugit (1.5.3) fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7) et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4) raabro (~> 1.4)
fuubar (2.5.1) fuubar (2.5.1)
@@ -602,7 +602,8 @@ GEM
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
redcarpet (3.5.1) redcarpet (3.5.1)
redis (4.7.0) redis-client (0.14.1)
connection_pool
regexp_parser (2.8.1) regexp_parser (2.8.1)
request_store (1.5.1) request_store (1.5.1)
rack (>= 1.4) rack (>= 1.4)
@@ -676,13 +677,15 @@ GEM
secure_headers (6.3.3) secure_headers (6.3.3)
shoulda-matchers (4.5.1) shoulda-matchers (4.5.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
sidekiq (6.5.1) sidekiq (7.1.2)
connection_pool (>= 2.2.2) concurrent-ruby (< 2)
rack (~> 2.0) connection_pool (>= 2.3.0)
redis (>= 4.2.0) rack (>= 2.2.4)
sidekiq-cron (1.6.0) redis-client (>= 0.14.0)
fugit (~> 1) sidekiq-cron (1.10.1)
sidekiq (>= 4.2.1) fugit (~> 1.8)
globalid (>= 1.0.1)
sidekiq (>= 6)
simple_captcha2 (0.5.0) simple_captcha2 (0.5.0)
rails (>= 4.1) rails (>= 4.1)
simple_oauth (0.3.1) simple_oauth (0.3.1)
@@ -869,7 +872,7 @@ DEPENDENCIES
rails-i18n (= 6.0.0) rails-i18n (= 6.0.0)
rails-timeago (= 2.20.0) rails-timeago (= 2.20.0)
redcarpet (= 3.5.1) redcarpet (= 3.5.1)
redis (= 4.7.0) redis-client (= 0.14.1)
responders (= 3.1.0) responders (= 3.1.0)
rqrcode (= 2.2.0) rqrcode (= 2.2.0)
rspec-json_expectations (~> 2.1) rspec-json_expectations (~> 2.1)
@@ -881,8 +884,8 @@ DEPENDENCIES
sassc-rails (= 2.1.2) sassc-rails (= 2.1.2)
secure_headers (= 6.3.3) secure_headers (= 6.3.3)
shoulda-matchers (= 4.5.1) shoulda-matchers (= 4.5.1)
sidekiq (= 6.5.1) sidekiq (= 7.1.2)
sidekiq-cron (= 1.6.0) sidekiq-cron (= 1.10.1)
simple_captcha2 (= 0.5.0) simple_captcha2 (= 0.5.0)
simplecov (= 0.21.2) simplecov (= 0.21.2)
sinon-rails (= 1.15.0) sinon-rails (= 1.15.0)

View File

@@ -30,7 +30,7 @@ class InvitationsController < ApplicationController
session[:invalid_email_invites] = invalid_emails session[:invalid_email_invites] = invalid_emails
unless valid_emails.empty? unless valid_emails.empty?
Workers::Mail::InviteEmail.perform_async(valid_emails.join(","), current_user.id, inviter_params) Workers::Mail::InviteEmail.perform_async(valid_emails.join(","), current_user.id, inviter_params.to_h)
end end
if emails.empty? if emails.empty?

View File

@@ -31,7 +31,7 @@ module Workers
!(Process.pid.to_s == process_id.split(":")[1] && Thread.current.object_id.to_s(36) == thread_id) && !(Process.pid.to_s == process_id.split(":")[1] && Thread.current.object_id.to_s(36) == thread_id) &&
ArchiveBase.subclasses.map(&:to_s).include?(work["payload"]["class"]) ArchiveBase.subclasses.map(&:to_s).include?(work["payload"]["class"])
end end
rescue Redis::CannotConnectError rescue RedisClient::CannotConnectError
# If code gets to this point and there is no Redis conenction, we're # If code gets to this point and there is no Redis conenction, we're
# running in a Test environment and have not mocked Sidekiq::Workers, so # running in a Test environment and have not mocked Sidekiq::Workers, so
# we're not testing the concurrency-limiting behavior. # we're not testing the concurrency-limiting behavior.

View File

@@ -128,7 +128,8 @@ if [ -n "$redis_url" ]
then then
redis_param="url: '$redis_url'" redis_param="url: '$redis_url'"
fi fi
if [ "$(bin/bundle exec ruby -e "require 'redis'; puts Redis.new($redis_param).ping" 2> /dev/null | grep -vE "is not writable|as your home directory temporarily" )" != "PONG" ] echo $redis_param
if [ "$(bin/bundle exec ruby -e "require 'redis-client'; puts RedisClient.config($redis_param).new_client.call('PING')" 2> /dev/null | grep -vE "is not writable|as your home directory temporarily" )" != "PONG" ]
then then
fatal "Can't connect to redis. Please check if it's running and if environment.redis is configured correctly in $CONFIG_FILE." fatal "Can't connect to redis. Please check if it's running and if environment.redis is configured correctly in $CONFIG_FILE."
fi fi

View File

@@ -39,7 +39,7 @@ describe InvitationsController, type: :controller do
it "creates an InviteEmail worker" do it "creates an InviteEmail worker" do
expect(Workers::Mail::InviteEmail).to receive(:perform_async).with( expect(Workers::Mail::InviteEmail).to receive(:perform_async).with(
emails, alice.id, invite_params[:email_inviter] emails, alice.id, invite_params[:email_inviter].stringify_keys
) )
post :create, params: invite_params post :create, params: invite_params
end end
@@ -85,7 +85,7 @@ describe InvitationsController, type: :controller do
it "creates an InviteEmail worker" do it "creates an InviteEmail worker" do
expect(Workers::Mail::InviteEmail).to receive(:perform_async).with( expect(Workers::Mail::InviteEmail).to receive(:perform_async).with(
valid_emails, alice.id, invite_params[:email_inviter] valid_emails, alice.id, invite_params[:email_inviter].stringify_keys
) )
post :create, params: invite_params post :create, params: invite_params
end end