Sha256: 1c5a3706d913ec94393779a40f8fd5b73cab139fbabcc38be21ef190f23eb310
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Sidekiq module Throttled # Queue name utility belt. # # @private module QueueName # RegExp used to stip out any redisr-namespace prefixes with `queue:`. QUEUE_NAME_PREFIX_RE = /.*queue:/ private_constant :QUEUE_NAME_PREFIX_RE class << self # Strips redis-namespace and `queue:` prefix from given queue name. # # @example # # QueueName.normalize "queue:default" # # => "default" # # QueueName.normalize "queue:queue:default" # # => "default" # # QueueName.normalize "foo:bar:queue:default" # # => "default" # # @param [#to_s] # @return [String] def normalize(queue) -queue.to_s.sub(QUEUE_NAME_PREFIX_RE, "") end # Prepends `queue:` prefix to given `queue` name. # # @note It does not normalizes queue before expanding it, thus # double-call of this method will potentially do some harm. # # @param [#to_s] queue Queue name # @return [String] def expand(queue) -"queue:#{queue}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-throttled-0.11.0 | lib/sidekiq/throttled/queue_name.rb |
sidekiq-throttled-0.10.0 | lib/sidekiq/throttled/queue_name.rb |