Sha256: 28140865d79d1cb3ee961eb36e2c9e7bf441cb72846e83249bf55c277bfba105

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require "crono_trigger/version"

require "ostruct"
require "socket"
require "active_record"
require "concurrent"
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,
    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

5 entries across 5 versions & 1 rubygems

Version Path
crono_trigger-0.6.4 lib/crono_trigger.rb
crono_trigger-0.6.3 lib/crono_trigger.rb
crono_trigger-0.6.2 lib/crono_trigger.rb
crono_trigger-0.6.1 lib/crono_trigger.rb
crono_trigger-0.6.0 lib/crono_trigger.rb