Sha256: c35b4cafa84e7df87f1b4018b1676227db23a25e0dffd5e23335d85877658607

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 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
      self
    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) }.empty?
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
containers_manager-0.1.12 lib/containers_manager/entities/consul_entry.rb