Sha256: 1c82eaec6991521ebee8b7b899704f047c25dda60ac089839565b8a7deffc7c7

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

require 'servicy/configurable'

module Servicy
  # Use this method to configure Servicy for other services
  def self.configure(&block)
    conf = Configurable.new

    # Give some reasonable defaults
    conf.server.host          = 'localhost'
    conf.server.transport     = Servicy::Transport.InMemory.new
    conf.server.load_balancer = Servicy::RoundRobinLoadBalancer.new
    conf.server.logger_stream = File.open(File.join('/var', 'log', 'servicy_server.log'), 'a')
    conf.server.config_file   = File.expand_path("~/.servicy.conf")
    # To set something for a given object, you would do something like:
    # conf.transport.port = 1234

    conf.client.transport = Servicy::Transport.InMemory.new
    conf.transport.format = Servicy::Formats.JSON

    conf = yield conf if block_given?
    raise ArgumentError("Return the config object, please") unless conf.is_a?(Configurable)

    # Set the options
    @_config = conf
  end

  def self.config
    @_config ||= configure
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
servicy-0.0.6 lib/servicy/config.rb