Sha256: a86517d1d8107406a2d981567785d70cc166e6cdd08a69842f0a77540c594fb8

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

class Envoy::Client::Config; end

class Envoy::Client::Config::Builder

  def initialize (config)
    @config = config
  end

  def run (path)
    instance_eval(File.read(path), path)
  end

  def set (name, value)
    @config.__send__("#{name}=", value)
  end

  def fetch (name, &block)
    if r = @config.__send__(name)
      r
    elsif block
      set(name, block.())
    end
  end

  def export (type, *args)
    case type
    when :tcp
      args = args[0].split(":") if args[0] and !args[1]
      args[0] ||= "127.0.0.1"
      args[1] ||= rand(16383) + 49152
      args = [:tcp, *args]
    when :unix
      args[0] ||= ".envoy.sock"
      args = [:unix, *args]
    end
    set :export, args
  end

  def localsock ()
    export(:unix)[1]
  end

  def localhost
    export(:tcp)[1]
  end

  def localport ()
    export(:tcp)[2]
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
envoy-proxy-1.0.3 lib/envoy/client/config/builder.rb
envoy-proxy-1.0.1 lib/envoy/client/config/builder.rb
envoy-proxy-1.0.0 lib/envoy/client/config/builder.rb