Sha256: c9efd0cc28d050c0132ace726c7060149ea0c4817368f5e7ec07180e2ee2109a

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'hashr'
require 'logger'
require 'vx/common/tagged_logging'

module Vx
  module Worker
    class Configuration < ::Hashr

      extend Hashr::EnvDefaults

      @@null_logger = Logger.new("/dev/null")

      self.env_namespace = 'vx'
      self.raise_missing_keys = true

      define amqp_url:     nil,
             run:          "docker",
             timeout:      30 * 60,
             logger:       Common::TaggedLogging.new(Logger.new STDOUT),

             workers:          1,
             path_prefix:      nil,

             docker: {
               user:       nil,
               password:   nil,
               init:       nil,
               image:      nil,
               remote_dir: nil
             },

             local: {
               remote_dir: nil
             }

      def timeout
        self[:timeout].to_i
      end

      def run
        self[:run].to_sym
      end

      def path_prefix
        self[:path_prefix] || Dir.pwd
      end

      def null_logger
        @@null_logger
      end

      def connector_options
        self[self.run]
      end

      def connector_remote_dir
        connector_options[:remote_dir]
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vx-worker-0.3.0.pre0 lib/vx/worker/configuration.rb
vx-worker-0.2.1 lib/vx/worker/configuration.rb