Sha256: 29633effc14fc07c644b760cb9162aed6d12430f36b8a29aded56b9381250e0e

Contents?: true

Size: 848 Bytes

Versions: 7

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

module Ductr
  #
  # Allowing a job to execute ETL runners.
  # You need to declare the ETL_RUNNER_CLASS constant in the including class:
  #
  #   class CustomJobClass < Job
  #     ETL_RUNNER_CLASS = ETL::KibaRunner
  #     include JobETLRunner
  #   end
  #
  # The job must have the #parse_annotations method defined, which can be added by including ETL::Parser.
  #
  module JobETLRunner
    #
    # Parse job's annotations and create the runner instance.
    #
    def initialize(...)
      super(...)

      @runner = self.class::ETL_RUNNER_CLASS.new(*parse_annotations)
    end

    #
    # Opens adapters, executes the runner and then closes back adapters.
    #
    # @return [void]
    #
    def run
      adapters.each(&:open!)
      @runner.run
    ensure
      adapters.each(&:close!)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ductr-0.2.3 lib/ductr/job_etl_runner.rb
ductr-0.2.2 lib/ductr/job_etl_runner.rb
ductr-0.2.1 lib/ductr/job_etl_runner.rb
ductr-0.2.0 lib/ductr/job_etl_runner.rb
ductr-0.1.2 lib/ductr/job_etl_runner.rb
ductr-0.1.1 lib/ductr/job_etl_runner.rb
ductr-0.1.0 lib/ductr/job_etl_runner.rb