Module: Karafka::Pro::ScheduledMessages::SchemaValidator

Defined in:
lib/karafka/pro/scheduled_messages/schema_validator.rb

Overview

Validator that checks if we can process this scheduled message If we encounter message that has a schema version higher than our process is aware of we raise and error and do not process. This is to make sure we do not deal with messages that are not compatible in case of schema changes.

Class Method Summary collapse

Class Method Details

.call(message) ⇒ Object

Check if we can work with this schema message and raise error if not.



26
27
28
29
30
31
32
# File 'lib/karafka/pro/scheduled_messages/schema_validator.rb', line 26

def call(message)
  message_version = message.headers['schedule_schema_version']

  return if message_version <= ScheduledMessages::SCHEMA_VERSION

  raise Errors::IncompatibleSchemaError, message_version
end