Sha256: cac3fa59796be49a6d83173310b33023ca7aa13370af03406eda387a0a9ce62f

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require_relative './railtie'

require 'active_support'
require 'rails_cloud_tasks/rack/errors'

module RailsCloudTasks
  extend ActiveSupport::Autoload

  autoload :Scheduler
  autoload :Credentials
  autoload :Adapter
  autoload :AppEngine
  autoload :Configuration
  autoload :Version
  autoload :Instrumentation

  module Rack
    extend ActiveSupport::Autoload

    autoload :Jobs
    autoload :Tasks
  end

  attr_writer :config

  def self.configure
    yield(config)
  end

  def self.config
    @config ||= Configuration.new
  end

  def self.logger
    return @logger if @logger

    @logger ||= (Rails.logger || Logger.new($stdout)).tap do |logger|
      logger.formatter = proc do |severity, datetime, _progname, msg|
        "[#{datetime}] #{severity} [rails-cloud-tasks]: #{msg}\n"
      end
    end
  end

  @queue_adapter = nil

  def queue_adapter
    @@queue_adapter
  end

  def self.queue_adapter
    @queue_adapter ||= Adapter.new
  rescue Errno::EHOSTDOWN => e
    raise e unless Rails.env.development?

    logger.warn('unable to setup adapter, falling back to :inline')
    logger.warn(e)

    :inline
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-cloud-tasks-0.0.4 lib/rails-cloud-tasks.rb