Skip to content

Commit

Permalink
Rename any_changes to any_unique_opts
Browse files Browse the repository at this point in the history
A small change to rename variable `any_changes` to `any_unique_opts`,
which is more appropriate giving its presence in the path where unique
options are constructed.
  • Loading branch information
brandur committed Apr 28, 2024
1 parent 0152af2 commit 89cff65
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def insert_many(args)
private def check_unique_job(insert_params, unique_opts, &block)
return block.call if unique_opts.nil?

any_changes = false
any_unique_opts = false
get_params = Driver::JobGetByKindAndUniquePropertiesParam.new(kind: insert_params.kind)

# It's extremely important here that this lock string format and algorithm
Expand All @@ -159,35 +159,35 @@ def insert_many(args)
lock_str += "kind=#{insert_params.kind}"

if unique_opts.by_args
any_changes = true
any_unique_opts = true
get_params.encoded_args = insert_params.encoded_args
lock_str += "&args=#{insert_params.encoded_args}"
end

if unique_opts.by_period
lower_period_bound = truncate_time(@time_now_utc.call, unique_opts.by_period).utc

any_changes = true
any_unique_opts = true
get_params.created_at = [lower_period_bound, lower_period_bound + unique_opts.by_period]
lock_str += "&period=#{lower_period_bound.strftime("%FT%TZ")}"
end

if unique_opts.by_queue
any_changes = true
any_unique_opts = true
get_params.queue = insert_params.queue
lock_str += "&queue=#{insert_params.queue}"
end

if unique_opts.by_state
any_changes = true
any_unique_opts = true
get_params.state = unique_opts.by_state
lock_str += "&state=#{unique_opts.by_state.join(",")}"
else
get_params.state = DEFAULT_UNIQUE_STATES
lock_str += "&state=#{DEFAULT_UNIQUE_STATES.join(",")}"
end

return block.call unless any_changes
return block.call unless any_unique_opts

@driver.transaction do
lock_key = if @advisory_lock_prefix.nil?
Expand Down

0 comments on commit 89cff65

Please sign in to comment.