chore(kredis): use default shared connection name, fixing dossier index debounce

This commit is contained in:
Colin Darie 2024-06-14 11:34:41 +02:00
parent 7a9b1a5763
commit 2dda5e44f9
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
3 changed files with 6 additions and 6 deletions

View file

@ -3,7 +3,7 @@ module LockableConcern
included do
def lock_action(key)
lock = Kredis.flag(key, config: :volatile)
lock = Kredis.flag(key)
head :locked and return if lock.marked?
lock.mark(expires_in: 10.seconds)

View file

@ -1,7 +1,7 @@
redis_volatile_options = {
redis_shared_options = {
url: ENV['REDIS_CACHE_URL'], # will fallback to default redis url if empty, and won't fail if there is no redis server
ssl: ENV['REDIS_CACHE_SSL'] == 'enabled'
}
redis_volatile_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
redis_shared_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
Kredis::Connections.connections[:volatile] = Redis.new(redis_volatile_options)
Kredis::Connections.connections[:shared] = Redis.new(redis_shared_options)

View file

@ -27,7 +27,7 @@ describe LockableConcern, type: :controller do
context 'when there are concurrent requests' do
it 'aborts the second request' do
# Simulating the first request acquiring the lock
Kredis.flag(lock_key, config: :volatile).mark(expires_in: 3.seconds)
Kredis.flag(lock_key).mark(expires_in: 3.seconds)
# Making the second request
expect(subject).to have_http_status(:locked)
@ -36,7 +36,7 @@ describe LockableConcern, type: :controller do
context 'when the lock expires' do
it 'allows another request after expiration' do
Kredis.flag(lock_key, config: :volatile).mark(expires_in: 0.001.seconds)
Kredis.flag(lock_key).mark(expires_in: 0.001.seconds)
sleep 0.002
expect(subject).to have_http_status(:ok)