Sha256: ec95ff55d51848c48c1ed2b5cdd1e1f12da8dc2b7fe5fd7ba0d5d224ce05b542

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

module Dryad
  module Consul
    class Service < Dryad::Core::Service
      def to_registers
        portals.map do |portal|
          {
            ID: portal.id,
            Name: Service.full_name(portal.schema, name),
            Address: address,
            Port: portal.port,
            EnableTagOverride: true,
            Tags: tags(portal),
            Checks: checks(portal)
          }
        end
      end

      private
      def tags(portal)
        tags = [
          "type = \"#{type_name}\"",
          "priority = \"#{priority}\"",
          "group = \"#{group}\"",
          "schema = \"#{portal.schema}\"",
          "pattern = \"#{portal.pattern}\""
        ]
        if portal.non_certifications.count > 0
          tags << "non_certifications = \"#{portal.non_certifications.join(",")}\""
        end
        tags.concat(load_balancing.map{|lb| "load_balancing = \"#{lb}\"" })
      end

      def checks(portal)
        if portal.check.nil? || !portal.check.is_a?(Dryad::Consul::HealthCheck)
          []
        else
          [portal.check.attributes]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dryad-consul-1.1.0 lib/dryad/consul/service.rb
dryad-consul-1.0.1 lib/dryad/consul/service.rb
dryad-consul-1.0.0 lib/dryad/consul/service.rb
dryad-consul-0.3.4 lib/dryad/consul/service.rb
dryad-consul-0.3.2 lib/dryad/consul/service.rb