class Kazoo::PatternSubscription
PatternSubscription
describes a subscription based on a regular expression that serves as either a whitelist or blacklist filter for all topics available in a Kafka cluster.
Constants
- PATTERN_TYPES
Attributes
pattern[R]
regexp[R]
Public Class Methods
new(regexp, pattern: :white_list, **kwargs)
click to toggle source
Calls superclass method
Kazoo::Subscription::new
# File lib/kazoo/subscription.rb, line 185 def initialize(regexp, pattern: :white_list, **kwargs) super(**kwargs) raise ArgumentError, "#{pattern.inspect} is not a valid pattern type" unless PATTERN_TYPES.include?(pattern) @regexp, @pattern = regexp, pattern end
Public Instance Methods
black_list?()
click to toggle source
Returns true if this subscription uses a blacklist pattern
# File lib/kazoo/subscription.rb, line 197 def black_list? pattern == :black_list end
has_topic?(topic)
click to toggle source
Returns true if the whitelist or blacklist does not filter out the provided topic.
# File lib/kazoo/subscription.rb, line 202 def has_topic?(topic) case pattern when :white_list; topic.name =~ regexp when :black_list; topic.name !~ regexp end end
white_list?()
click to toggle source
Returns true if this subscription uses a whitelist pattern
# File lib/kazoo/subscription.rb, line 192 def white_list? pattern == :white_list end
Protected Instance Methods
subscription()
click to toggle source
# File lib/kazoo/subscription.rb, line 211 def subscription { regexp.inspect[1..-2] => 1 } end