Sha256: 8193d9254b993a70bb9cf64262409f70d352f5d7bffb8c543f9752e3991c18e7

Contents?: true

Size: 763 Bytes

Versions: 2

Compression:

Stored size: 763 Bytes

Contents

require_relative 'entity'

module Services
  # This is a service member usually something that
  # would be sitting behind some VIP
  class Member < Services::Entity
    attr_accessor :ip, :port, :proto, :service, :weight
    def initialize(name, args = {})
      @ip = args[:ip] || ''
      @proto = args[:proto] || 'http'
      @port  = args[:port]  || 80
      @weight = args[:weight] || 20
      @service = args[:service]
      @path = "#{service}/members/#{name}"
      super
    end

    private

    def validate
      unless @service
        fail ArgumentError,
             "#{self.class} requires service: argument"
      end

      unless name
        fail ARgumentError,
             "#{self.class} requires name argument"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jn_services-1.0.1 lib/services/member.rb
jn_services-1.0.0 lib/services/member.rb