Class: RServiceBus::ConfigureAppResource

Inherits:
Object
  • Object
show all
Defined in:
lib/rservicebus/appresource_configure.rb

Overview

Configure AppResources for an rservicebus host

Instance Method Summary collapse

Instance Method Details

#get_resources(env, host, state_manager, saga_storage) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rservicebus/appresource_configure.rb', line 6

def get_resources(env, host, state_manager, saga_storage)
  # rm = resource_manager
  rm = ResourceManager.new(state_manager, saga_storage)
  env.each do |k, v|
    if v.is_a?(String) && k.start_with?('RSBFDB_')
      uri = URI.parse(v)
      require 'rservicebus/appresource/fluiddb'
      rm.add k.sub('RSBFDB_', ''), AppResourceFluidDb.new(host, uri)
    elsif v.is_a?(String) && k.start_with?('RSB_')
      uri = URI.parse(v)
      case uri.scheme
      when 'dir'
        require 'rservicebus/appresource/dir'
        rm.add k.sub('RSB_', ''), AppResourceDir.new(host, uri)
      when 'file'
        require 'rservicebus/appresource/file'
        rm.add k.sub('RSB_', ''), AppResourceFile.new(host, uri)
      else
        abort("Scheme, #{uri.scheme}, not recognised when configuring
              app resource, #{k}=#{v}")
      end
    end
  end

  rm
end