Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated uses of Redis#pipelined #150

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lib/stoplight/data_store/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def names
end

def get_all(light)
failures, state = @redis.multi do
query_failures(light)
@redis.hget(states_key, light.name)
failures, state = @redis.multi do |transaction|
query_failures(light, transaction: transaction)
transaction.hget(states_key, light.name)
end

[
Expand All @@ -41,18 +41,18 @@ def get_failures(light)
end

def record_failure(light, failure)
size, = @redis.multi do
@redis.lpush(failures_key(light), failure.to_json)
@redis.ltrim(failures_key(light), 0, light.threshold - 1)
size, = @redis.multi do |transaction|
transaction.lpush(failures_key(light), failure.to_json)
transaction.ltrim(failures_key(light), 0, light.threshold - 1)
end

size
end

def clear_failures(light)
failures, = @redis.multi do
query_failures(light)
@redis.del(failures_key(light))
failures, = @redis.multi do |transaction|
query_failures(light, transaction: transaction)
transaction.del(failures_key(light))
end

normalize_failures(failures, light.error_notifier)
Expand All @@ -68,18 +68,18 @@ def set_state(light, state)
end

def clear_state(light)
state, = @redis.multi do
query_state(light)
@redis.hdel(states_key, light.name)
state, = @redis.multi do |transaction|
query_state(light, transaction: transaction)
transaction.hdel(states_key, light.name)
end

normalize_state(state)
end

private

def query_failures(light)
@redis.lrange(failures_key(light), 0, -1)
def query_failures(light, transaction: @redis)
transaction.lrange(failures_key(light), 0, -1)
end

def normalize_failures(failures, error_notifier)
Expand All @@ -91,8 +91,8 @@ def normalize_failures(failures, error_notifier)
end
end

def query_state(light)
@redis.hget(states_key, light.name)
def query_state(light, transaction: @redis)
transaction.hget(states_key, light.name)
end

def normalize_state(state)
Expand Down