Module: CDC::Core::Operation

Defined in:
lib/cdc/core/operation.rb

Overview

Canonical CDC operation names.

Operations are represented as symbols to keep event objects small, immutable, and easy to compare. Use .normalize when accepting user input and .supported? when validating optional values.

Constant Summary collapse

INSERT =

Insert row operation.

:insert
UPDATE =

Update row operation.

:update
DELETE =

Delete row operation.

:delete
TRUNCATE =

Truncate table operation.

:truncate
MESSAGE =

Logical replication message operation.

:message
SUPPORTED =

All operation names currently recognized by cdc-core.

Ractor.make_shareable([INSERT, UPDATE, DELETE, TRUNCATE, MESSAGE].freeze)
MVP =

Minimal row-change operations used by the initial runtime surface.

Ractor.make_shareable([INSERT, UPDATE, DELETE].freeze)

Class Method Summary collapse

Class Method Details

.normalize(operation) ⇒ Symbol

Convert an operation-like value into a supported operation symbol.

Parameters:

  • operation (#to_sym)

    value to normalize

Returns:

  • (Symbol)

    one of SUPPORTED

Raises:



33
34
35
36
37
38
# File 'lib/cdc/core/operation.rb', line 33

def normalize(operation)
  value = operation.to_sym
  return value if SUPPORTED.include?(value)

  raise InvalidOperationError, "unsupported CDC operation: #{operation.inspect}"
end

.supported?(operation) ⇒ Boolean

Check whether an operation-like value is supported.

Parameters:

  • operation (#to_sym)

    value to check

Returns:

  • (Boolean)

    true when the value normalizes to a supported operation



44
45
46
47
48
# File 'lib/cdc/core/operation.rb', line 44

def supported?(operation)
  SUPPORTED.include?(operation.to_sym)
rescue NoMethodError
  false
end