Sha256: 0a5ded8f4e01c38c114adf4e29333f431f93f3970440f2b6bb542157c4b088ee

Contents?: true

Size: 897 Bytes

Versions: 20

Compression:

Stored size: 897 Bytes

Contents

module MCollective
  class Discovery
    class Mc
      def self.discover(filter, timeout, limit, client)
        begin
          hosts = []
          Timeout.timeout(timeout) do
            reqid = client.sendreq("ping", "discovery", filter)
            Log.debug("Waiting #{timeout} seconds for discovery replies to request #{reqid}")

            loop do
              reply = client.receive(reqid)
              Log.debug("Got discovery reply from #{reply.payload[:senderid]}")
              hosts << reply.payload[:senderid]

              return hosts if limit > 0 && hosts.size == limit
            end
          end
        rescue Timeout::Error # rubocop:disable Lint/SuppressedException
        rescue Exception # rubocop:disable Lint/RescueException
          raise
        ensure
          client.unsubscribe("discovery", :reply)
        end

        hosts
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
choria-mcorpc-support-2.26.5 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.26.4 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.26.3 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.26.2 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.26.1 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.26.0 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.25.3 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.25.2 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.25.1 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.25.0 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.24.4 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.24.3 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.24.2 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.24.1 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.24.0 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.23.3 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.23.2 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.23.1 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.23.0 lib/mcollective/discovery/mc.rb
choria-mcorpc-support-2.23.0.pre lib/mcollective/discovery/mc.rb