Sha256: 6d68332e139864c530ff90b556f0c3eafaab8ac913df99b578c35ee8a414c0be

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

require "crono_trigger/version"

require "ostruct"
require "socket"
require "active_record"
require "concurrent"
require "crono_trigger/events"
require "crono_trigger/models/worker"
require "crono_trigger/models/signal"
require "crono_trigger/models/execution"
require "crono_trigger/worker"
require "crono_trigger/polling_thread"
require "crono_trigger/schedulable"

module CronoTrigger
  @config = OpenStruct.new(
    worker_id: Socket.ip_address_list.detect { |info| !info.ipv4_loopback? && !info.ipv6_loopback? }.ip_address,
    polling_thread: nil,
    polling_interval: 5,
    executor_thread: 25,
    fetch_records: nil, # default is executor_thread * 3
    model_names: nil,
    error_handlers: [],
    global_error_handlers: [],
  )

  def self.config
    @config
  end

  def self.configure
    yield config
  end

  def self.reloader
    @reloader
  end

  def self.reloader=(reloader)
    @reloader = reloader
  end

  self.reloader = proc { |&block| block.call }

  def self.load_config(yml, environment = nil)
    config = YAML.load_file(yml)[environment || "default"]
    config.each do |k, v|
      @config[k] = v
    end
  end

  def self.workers
    CronoTrigger::Models::Worker.alive_workers
  end
end

if defined?(Rails)
  require "crono_trigger/railtie"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crono_trigger-0.8.1 lib/crono_trigger.rb
crono_trigger-0.8.0 lib/crono_trigger.rb
crono_trigger-0.7.1 lib/crono_trigger.rb
crono_trigger-0.7.0 lib/crono_trigger.rb