Class: Aws::KCLrb::KCLProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/kclrb/kcl_process.rb

Overview

Entry point for a KCL application in Ruby.

Implementers of KCL applications in Ruby should instantiate this class and invoke the #run method to start processing records.

Instance Method Summary collapse

Constructor Details

#initialize(processor, input = $stdin, output = $stdout, error = $stderr) ⇒ KCLProcess

Returns a new instance of KCLProcess.

Parameters:

  • processor (RecordProcessorBase)

    A record processor to use for processing a shard.

  • input (IO) (defaults to: $stdin)

    An IO-like object to read input lines from.

  • output (IO) (defaults to: $stdout)

    An IO-like object to write output lines to.

  • error (IO) (defaults to: $stderr)

    An IO-like object to write error lines to.



27
28
29
30
31
32
33
34
35
# File 'lib/aws/kclrb/kcl_process.rb', line 27

def initialize(processor, input = $stdin, output = $stdout, error = $stderr)
  if processor.version == 1
    @processor = Aws::KCLrb::V2::V2ToV1Adapter.new(processor)
  else
    @processor = processor
  end
  @io_proxy = IOProxy.new(input, output, error)
  @checkpointer = CheckpointerImpl.new(@io_proxy)
end

Instance Method Details

#runObject

Starts this KCL processor's main loop.



38
39
40
41
42
43
44
# File 'lib/aws/kclrb/kcl_process.rb', line 38

def run
  action = @io_proxy.read_action
  while action do
    process_action(action)
    action = @io_proxy.read_action
  end
end