Sha256: 7dae207e37ca6a5929f8ff0394bfcc9cd5a1342521aef26148192991b8f54297

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

require 'forwardable'
require 'securerandom'
require 'redis'
require 'ost'
require 'class_config'
require 'transparent_proxy'
require 'logger'
require 'multi_require'

MultiRequire.require_relative_pattern 'asynchronic/**/*.rb'

module Asynchronic

  extend ClassConfig

  attr_config :default_queue, :asynchronic
  attr_config :queue_engine, QueueEngine::InMemory.new
  attr_config :data_store, DataStore::InMemory.new
  attr_config :logger, Logger.new($stdout)
  attr_config :retry_timeout, 30
  attr_config :garbage_collector_timeout, 30
  attr_config :redis_data_store_sync_timeout, 0.01

  def self.environment
    Environment.new queue_engine, data_store
  end

  def self.[](pid)
    environment.load_process pid
  end

  def self.processes
    environment.processes
  end

  def self.garbage_collector
    @garbage_collector ||= GarbageCollector.new environment, garbage_collector_timeout
  end

  def self.retry_execution(klass, message)
    begin
      result = yield
    rescue Exception => ex
      logger.error(klass) { "Retrying #{message}. ERROR: #{ex.message}" }
      sleep retry_timeout
      retry
    end
    result
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asynchronic-1.6.3 lib/asynchronic.rb
asynchronic-1.6.2 lib/asynchronic.rb
asynchronic-1.6.1 lib/asynchronic.rb
asynchronic-1.6.0 lib/asynchronic.rb
asynchronic-1.5.2 lib/asynchronic.rb
asynchronic-1.5.1 lib/asynchronic.rb