Class: Pgoutput::Client::Configuration
- Inherits:
-
Object
- Object
- Pgoutput::Client::Configuration
- Defined in:
- lib/pgoutput/client/configuration.rb
Overview
Immutable configuration for a PostgreSQL logical replication stream.
A configuration describes how ‘pgoutput-client` should connect to PostgreSQL and how it should request logical replication from the server. It deliberately contains transport-level settings only; parsing pgoutput records and decoding PostgreSQL values belong to downstream layers.
The object freezes itself and its string/array attributes during initialization so it can be safely shared by transport components without defensive copying.
Constant Summary collapse
- DEFAULT_PLUGIN =
Default logical decoding output plugin.
"pgoutput"- DEFAULT_PROTO_VERSION =
Default pgoutput protocol version.
1- DEFAULT_FEEDBACK_INTERVAL =
Default interval, in seconds, between standby status feedback messages.
10.0
Instance Attribute Summary collapse
-
#auto_create_slot ⇒ Boolean
readonly
Whether the client should create the slot before streaming.
-
#binary ⇒ Boolean
readonly
Whether to request binary column values from pgoutput.
-
#database_url ⇒ String
readonly
PostgreSQL connection URL.
- #feedback_interval ⇒ Object readonly
-
#messages ⇒ Boolean
readonly
Whether to request logical decoding messages from pgoutput.
-
#plugin ⇒ String
readonly
Logical decoding output plugin name.
-
#proto_version ⇒ Integer
readonly
pgoutput protocol version.
-
#publication_names ⇒ Array<String>
readonly
Publication names requested from pgoutput.
-
#slot_name ⇒ String
readonly
Logical replication slot name.
-
#start_lsn ⇒ String?
readonly
Optional normalized starting LSN.
-
#temporary_slot ⇒ Boolean
readonly
Whether a newly created slot should be temporary.
Instance Method Summary collapse
-
#initialize(database_url:, slot_name:, publication_names:, start_lsn: nil, plugin: DEFAULT_PLUGIN, proto_version: DEFAULT_PROTO_VERSION, binary: false, messages: false, auto_create_slot: false, temporary_slot: false, feedback_interval: DEFAULT_FEEDBACK_INTERVAL) ⇒ void
constructor
Build and validate a logical replication stream configuration.
-
#start_lsn_string ⇒ String
Starting LSN to render in ‘START_REPLICATION`.
Constructor Details
#initialize(database_url:, slot_name:, publication_names:, start_lsn: nil, plugin: DEFAULT_PLUGIN, proto_version: DEFAULT_PROTO_VERSION, binary: false, messages: false, auto_create_slot: false, temporary_slot: false, feedback_interval: DEFAULT_FEEDBACK_INTERVAL) ⇒ void
Build and validate a logical replication stream configuration.
‘slot_name` and every publication name are intentionally limited to simple PostgreSQL identifier-like strings. This keeps command rendering small and predictable while avoiding quoting rules in this transport layer.
Boolean options are normalized with Ruby truthiness. ‘nil` and `false` become `false`; all other values become `true`.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/pgoutput/client/configuration.rb', line 125 def initialize(database_url:, slot_name:, publication_names:, start_lsn: nil, plugin: DEFAULT_PLUGIN, proto_version: DEFAULT_PROTO_VERSION, binary: false, messages: false, auto_create_slot: false, temporary_slot: false, feedback_interval: DEFAULT_FEEDBACK_INTERVAL) @database_url = String(database_url).freeze @slot_name = validate_identifier(slot_name, "slot_name").freeze @publication_names = Array(publication_names).map do |name| validate_identifier(name, "publication_name").freeze end.freeze @start_lsn = normalize_lsn(start_lsn).freeze @plugin = String(plugin).freeze @proto_version = Integer(proto_version) @binary = boolean(binary, "binary") @messages = boolean(, "messages") @auto_create_slot = boolean(auto_create_slot, "auto_create_slot") @temporary_slot = boolean(temporary_slot, "temporary_slot") @feedback_interval = Float(feedback_interval) validate! freeze end |
Instance Attribute Details
#auto_create_slot ⇒ Boolean (readonly)
Whether the client should create the slot before streaming.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#binary ⇒ Boolean (readonly)
Whether to request binary column values from pgoutput.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#database_url ⇒ String (readonly)
PostgreSQL connection URL.
82 83 84 |
# File 'lib/pgoutput/client/configuration.rb', line 82 def database_url @database_url end |
#feedback_interval ⇒ Object (readonly)
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#messages ⇒ Boolean (readonly)
Whether to request logical decoding messages from pgoutput.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#plugin ⇒ String (readonly)
Logical decoding output plugin name.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#proto_version ⇒ Integer (readonly)
pgoutput protocol version.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#publication_names ⇒ Array<String> (readonly)
Publication names requested from pgoutput.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#slot_name ⇒ String (readonly)
Logical replication slot name.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#start_lsn ⇒ String? (readonly)
Optional normalized starting LSN.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
#temporary_slot ⇒ Boolean (readonly)
Whether a newly created slot should be temporary.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pgoutput/client/configuration.rb', line 82 attr_reader :database_url, :slot_name, :publication_names, :start_lsn, :plugin, :proto_version, :binary, :messages, :auto_create_slot, :temporary_slot, :feedback_interval |
Instance Method Details
#start_lsn_string ⇒ String
Starting LSN to render in ‘START_REPLICATION`.
157 158 159 |
# File 'lib/pgoutput/client/configuration.rb', line 157 def start_lsn_string start_lsn || "0/0" end |