Module: Sensu::Settings

Defined in:
lib/sensu/settings.rb,
lib/sensu/settings/rules.rb,
lib/sensu/settings/loader.rb,
lib/sensu/settings/validator.rb,
lib/sensu/settings/constants.rb,
lib/sensu/settings/validators.rb,
lib/sensu/settings/validators/api.rb,
lib/sensu/settings/validators/check.rb,
lib/sensu/settings/validators/client.rb,
lib/sensu/settings/validators/filter.rb,
lib/sensu/settings/validators/subdue.rb,
lib/sensu/settings/validators/mutator.rb,
lib/sensu/settings/validators/handler.rb,
lib/sensu/settings/validators/transport.rb

Defined Under Namespace

Modules: Rules, Validators Classes: Loader, Validator

Constant Summary collapse

CATEGORIES =
[:checks, :filters, :mutators, :handlers]

Class Method Summary collapse

Class Method Details

.get(options = {}) ⇒ Loader

Retrieve the current loaded settings loader or load one up if there isn't one. Note: We may need to add a mutex for thread safety.


37
38
39
# File 'lib/sensu/settings.rb', line 37

def get(options={})
  @loader || load(options)
end

.load(options = {}) ⇒ Loader

Load Sensu settings.

Options Hash (options):

  • :config_file (String)

    to load.

  • :config_dir (String)

    to load.

  • :config_dirs (Array)

    to load.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sensu/settings.rb', line 13

def load(options={})
  @loader = Loader.new
  @loader.load_env
  if options[:config_file]
    @loader.load_file(options[:config_file])
  end
  if options[:config_dir]
    @loader.load_directory(options[:config_dir])
  end
  if options[:config_dirs]
    options[:config_dirs].each do |directory|
      @loader.load_directory(directory)
    end
  end
  @loader.set_env!
  @loader
end