Class: CDC::Core::SourceAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/cdc/core/source_adapter.rb

Overview

Abstract base class for source adapters that normalize upstream payloads into CDC core domain objects.

SourceAdapter is intentionally narrow. It does not own transport, polling, connection management, worker scheduling, or protocol parsing. It only defines the contract for turning source-specific inputs into ChangeEvent, TransactionEnvelope, or arrays of those objects.

The concrete PostgreSQL implementation currently lives in the pgoutput* family. This class only defines the shared boundary other adapters can implement later.

Instance Method Summary collapse

Instance Method Details

#normalize(_input) ⇒ ChangeEvent, ...

Normalize one source payload into CDC core objects.

Subclasses must override this method.

Parameters:

  • _input (Object)

    source-specific payload

Returns:

Raises:

  • (NotImplementedError)

    when not implemented by a subclass



24
25
26
# File 'lib/cdc/core/source_adapter.rb', line 24

def normalize(_input)
  raise NotImplementedError, "#{self.class} must implement #normalize"
end

#normalize_many(inputs) ⇒ Array

Normalize many source payloads into CDC core objects.

The default implementation maps each input through #normalize and flattens one level so adapters can return a single object or a batch of objects for each payload.

Parameters:

  • inputs (Enumerable)

    source-specific payloads

Returns:

  • (Array)


36
37
38
# File 'lib/cdc/core/source_adapter.rb', line 36

def normalize_many(inputs)
  Array(inputs).flat_map { |input| normalize(input) }.freeze
end