Sha256: 16655602b314b4435d49993414a1b51b56939603ca97b6abd0cb0ca4bac78571

Contents?: true

Size: 1.27 KB

Versions: 104

Compression:

Stored size: 1.27 KB

Contents

module Embulk
  module Output

    class ExampleOutputPlugin < OutputPlugin
      # output plugin file name must be: embulk/output/<name>.rb
      Plugin.register_output('example', self)

      def self.transaction(config, schema, count, &control)
        task = {
          'message' => config.param('message', :string, default: "record")
        }

        resume(task, schema, count, &control)
      end

      def self.resume(task, schema, count, &control)
        puts "Example output started."
        task_reports = yield(task)
        puts "Example output finished. Commit reports = #{task_reports.to_json}"

        next_config_diff = {}
        return next_config_diff
      end

      def initialize(task, schema, index)
        puts "Example output thread #{index}..."
        super
        @message = task.param('message', :string)
        @records = 0
      end

      def close
      end

      def add(page)
        page.each do |record|
          hash = Hash[schema.names.zip(record)]
          STDOUT.write "#{@message}: #{hash.to_json}\n"
          @records += 1
        end
      end

      def finish
      end

      def abort
      end

      def commit
        task_report = {
          "records" => @records
        }
        return task_report
      end
    end

  end
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
embulk-0.8.0 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.0-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.10 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.10-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.9 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.9-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.8 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.8-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.7 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.7-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.6 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.6-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.5 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.5-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.4 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.4-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.3 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.3-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.2 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.7.2-java lib/embulk/data/bundle/embulk/output/example.rb