Sha256: 3994fc4480d6f2c3e3114a8ad352d444859065911b72ef92693ea3425599fa35

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

require 'hocon'
require 'bolt_server/base_config'
require 'bolt/error'

module PlanExecutor
  class Config < BoltServer::BaseConfig
    def config_keys
      super + %w[modulepath workers]
    end

    def defaults
      super.merge(
        'port' => 62659,
        'workers' => 1
      )
    end

    def service_name
      'plan-executor'
    end

    def load_env_config
      env_keys.each do |key|
        transformed_key = "BOLT_#{key.tr('-', '_').upcase}"
        next unless ENV.key?(transformed_key)
        @data[key] = ENV[transformed_key]
      end
    end

    def validate
      super
      unless natural?(@data['workers'])
        raise Bolt::ValidationError, "Configured 'workers' must be a positive integer"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bolt-1.10.0 lib/plan_executor/config.rb
bolt-1.9.0 lib/plan_executor/config.rb
bolt-1.8.1 lib/plan_executor/config.rb
bolt-1.8.0 lib/plan_executor/config.rb