Class: RubyKafkaRetryValidator

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/ruby_kafka_retry_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(retry_topic, dlq_topic, message) ⇒ RubyKafkaRetryValidator

Returns a new instance of RubyKafkaRetryValidator.



10
11
12
13
14
# File 'lib/ruby_kafka_retry_validator.rb', line 10

def initialize(retry_topic, dlq_topic, message)
  @retry_topic = retry_topic
  @dlq_topic = dlq_topic
  @message = message
end

Instance Attribute Details

#dlq_topicObject

Returns the value of attribute dlq_topic.



4
5
6
# File 'lib/ruby_kafka_retry_validator.rb', line 4

def dlq_topic
  @dlq_topic
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/ruby_kafka_retry_validator.rb', line 4

def message
  @message
end

#original_topicObject

Returns the value of attribute original_topic.



4
5
6
# File 'lib/ruby_kafka_retry_validator.rb', line 4

def original_topic
  @original_topic
end

#retry_topicObject

Returns the value of attribute retry_topic.



4
5
6
# File 'lib/ruby_kafka_retry_validator.rb', line 4

def retry_topic
  @retry_topic
end

Instance Method Details

#validateObject



16
17
18
19
20
# File 'lib/ruby_kafka_retry_validator.rb', line 16

def validate
  validate_retry_topic
  validate_dlq_topic
  validate_message
end

#validate_dlq_topicObject



26
27
28
# File 'lib/ruby_kafka_retry_validator.rb', line 26

def validate_dlq_topic
  raise "Validation failed: DLQ topic shouldn't be blank" unless dlq_topic.present?
end

#validate_messageObject



30
31
32
# File 'lib/ruby_kafka_retry_validator.rb', line 30

def validate_message
  raise "Validation failed: Topic message must be a non-empty Hash" unless(message.present? && message.is_a?(Hash))
end

#validate_retry_topicObject



22
23
24
# File 'lib/ruby_kafka_retry_validator.rb', line 22

def validate_retry_topic
  raise "Validation failed: Retry topic shouldn't be blank" unless retry_topic.present?
end