Class: Allora::Backend

Inherits:
Object
  • Object
show all
Defined in:
lib/allora/backend.rb

Direct Known Subclasses

Memory, Redis

Defined Under Namespace

Classes: Memory, Redis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Backend

Initialize the backend with the given options Hash.

Parameters:

  • opts (Hash) (defaults to: {})

    options for the backend, if the backend requires any



32
33
34
# File 'lib/allora/backend.rb', line 32

def initialize(opts = {})
  @options = opts
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



26
27
28
# File 'lib/allora/backend.rb', line 26

def options
  @options
end

Instance Method Details

#reschedule(jobs) ⇒ Hash

Reschedules jobs in the given Hash and returns those that should run now.

Subclasses should take an approach that tracks the run time information and updates it in a way that avoids race conditions. The job should not be run until it can be guaranteed that it has been rescheduled for a future time and no other scheduler process executed the job first.

Parameters:

  • jobs (Hash)

    a Hash mapping job names with their job classes

Returns:

  • (Hash)

    a Hash containing the jobs to be run now, if any

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/allora/backend.rb', line 48

def reschedule(jobs)
  raise NotImplementedError, "Abstract method #reschedule must be implemented by subclass"
end