Sha256: 1f1037ab28167d50846dedbbfa4bea964a4e037e64d201fae106835db4a63567

Contents?: true

Size: 646 Bytes

Versions: 6

Compression:

Stored size: 646 Bytes

Contents

module ContainersManager
  class ConsulEntry
    def initialize(data, configuration)
      @data          = data
      @configuration = configuration
    end

    def set_id_provider(id_provider)
      @id_provider = id_provider
    end

    def deregister_if_possible
      deregister if can_deregister?
    end

    private

    attr_reader :data, :configuration, :id_provider

    def deregister
      ConsulService.new(configuration).deregister(service_id)
    end

    def can_deregister?
      id_provider.alive_ids.find { |id| service_id.include?(id) }
    end

    def service_id
      @service_id ||= data['ServiceID']
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
containers_manager-0.1.10 lib/containers_manager/entities/consul_entry.rb
containers_manager-0.1.9 lib/containers_manager/entities/consul_entry.rb
containers_manager-0.1.8 lib/containers_manager/entities/consul_entry.rb
containers_manager-0.1.7 lib/containers_manager/entities/consul_entry.rb
containers_manager-0.1.6 lib/containers_manager/entities/consul_entry.rb
containers_manager-0.1.5 lib/containers_manager/entities/consul_entry.rb