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.39 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.39-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.38 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.38-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.37 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.37-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.36 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.36-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.35 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.35-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.34 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.34-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.33 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.33-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.32 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.32-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.31 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.31-java lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.30 lib/embulk/data/bundle/embulk/output/example.rb
embulk-0.8.30-java lib/embulk/data/bundle/embulk/output/example.rb