Class: GammaReplication::MaxwellClient
- Inherits:
-
Object
- Object
- GammaReplication::MaxwellClient
- Defined in:
- lib/gamma_replication/maxwell_client.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#maxwell_path ⇒ Object
readonly
Returns the value of attribute maxwell_path.
Instance Method Summary collapse
-
#initialize(config_path:, maxwell_path: "./maxwell") ⇒ MaxwellClient
constructor
A new instance of MaxwellClient.
- #start(&block) ⇒ Object
Constructor Details
#initialize(config_path:, maxwell_path: "./maxwell") ⇒ MaxwellClient
Returns a new instance of MaxwellClient.
10 11 12 13 |
# File 'lib/gamma_replication/maxwell_client.rb', line 10 def initialize(config_path:, maxwell_path: "./maxwell") @config_path = config_path @maxwell_path = maxwell_path end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
8 9 10 |
# File 'lib/gamma_replication/maxwell_client.rb', line 8 def config_path @config_path end |
#maxwell_path ⇒ Object (readonly)
Returns the value of attribute maxwell_path.
8 9 10 |
# File 'lib/gamma_replication/maxwell_client.rb', line 8 def maxwell_path @maxwell_path end |
Instance Method Details
#start(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gamma_replication/maxwell_client.rb', line 15 def start(&block) cmd = "#{maxwell_path}/bin/maxwell --config #{config_path}" IO.popen(cmd) do |io| io.each do |line| data = JSON.parse(line.strip) block.call(data) if block_given? rescue JSON::ParserError # Ignore Maxwell's non-JSON output (startup messages, etc) next end end end |