Class: Ductr::Job

Inherits:
ActiveJob::Base
  • Object
show all
Extended by:
Annotable, Forwardable
Includes:
JobStatus
Defined in:
lib/ductr/job.rb

Overview

The base class for any job, you can use it directly if you don’t need an ETL job.

Direct Known Subclasses

ETLJob, KibaJob, Pipeline

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JobStatus

included, #status=, #stopped?

Instance Attribute Details

#errorException (readonly)

Returns The occurred error if any.

Returns:

  • (Exception)

    The occurred error if any



14
15
16
# File 'lib/ductr/job.rb', line 14

def error
  @error
end

#statusSymbol (readonly)

Returns The job’s status, one of ‘:queued`, `:working`, `:completed` and `:failed`.

Returns:

  • (Symbol)

    The job’s status, one of ‘:queued`, `:working`, `:completed` and `:failed`



16
17
18
# File 'lib/ductr/job.rb', line 16

def status
  @status
end

Instance Method Details

#adapter(name) ⇒ Adapter

The configured adapter instances.

Parameters:

  • name (Symbol)

    The adapter name

Returns:

  • (Adapter)

    The adapter corresponding to the given name



36
37
38
# File 'lib/ductr/job.rb', line 36

def adapter(name)
  Ductr.config.adapter(name)
end

#loggerDuctr::Log::Logger

The job’s logger instance.

Returns:



45
46
47
# File 'lib/ductr/job.rb', line 45

def logger
  @logger ||= Ductr.config.logging.new(self.class)
end

#perform(*_) ⇒ void

This method returns an undefined value.

The active job’s perform method. DO NOT override it, implement the #run method instead.



25
26
27
# File 'lib/ductr/job.rb', line 25

def perform(*_)
  run
end

#runvoid

This method returns an undefined value.

The entry point of jobs.

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/ductr/job.rb', line 54

def run
  raise NotImplementedError, "A job must implement the `#run` method"
end