class Proxy::Dynflow

Constants

VERSION

Attributes

instance[R]
world[RW]

Public Class Methods

after_initialize(&block) click to toggle source
# File lib/smart_proxy_dynflow.rb, line 78
def after_initialize(&block)
  after_initialize_blocks << block
end
ensure_initialized() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 53
def ensure_initialized
  return @instance if @instance
  @instance = Proxy::Dynflow.new
  after_initialize_blocks.each(&:call)
  @instance
end
new() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 11
def initialize
  @world = create_world
end
web_console() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 60
def web_console
  require 'dynflow/web'
  dynflow_console = ::Dynflow::Web.setup do
    # we can't use the proxy's after_actionvation hook, as
    # it happens before the Daemon forks the process (including
    # closing opened file descriptors)
    # TODO: extend smart proxy to enable hooks that happen after
    # the forking
    Proxy::Dynflow.ensure_initialized
    set :world, Proxy::Dynflow.world
  end
  dynflow_console
end
world() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 74
def world
  instance.world
end

Private Class Methods

after_initialize_blocks() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 84
def after_initialize_blocks
  @after_initialize_blocks ||= []
end

Public Instance Methods

create_world(&block) click to toggle source
# File lib/smart_proxy_dynflow.rb, line 15
def create_world(&block)
  config = default_world_config(&block)
  ::Dynflow::World.new(config)
end
default_world_config() { |config| ... } click to toggle source
# File lib/smart_proxy_dynflow.rb, line 37
def default_world_config
  ::Dynflow::Config.new.tap do |config|
    config.auto_rescue = true
    config.logger_adapter = logger_adapter
    config.persistence_adapter = persistence_adapter
    yield config if block_given?
  end
end
logger_adapter() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 46
def logger_adapter
  ::Dynflow::LoggerAdapters::Simple.new $stderr, 0
end
persistence_adapter() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 33
def persistence_adapter
  ::Dynflow::PersistenceAdapters::Sequel.new persistence_conn_string
end
persistence_conn_string() click to toggle source
# File lib/smart_proxy_dynflow.rb, line 20
def persistence_conn_string
  db_conn_string = 'sqlite:/'

  db_file = Proxy::Dynflow::Plugin.settings.database
  if db_file.nil? || db_file.empty?
    Proxy::Log.logger.warn "Could not open DB for dynflow at '#{db_file}', will keep data in memory. Restart will drop all dynflow data."
  else
    db_conn_string += "/#{db_file}"
  end

  ENV['DYNFLOW_DB_CONN_STRING'] || db_conn_string
end