Sha256: f0d9f7e945378f8313ac4383f42ffd29d75664d9bed803bf0b5f1c57ee3bbc52

Contents?: true

Size: 772 Bytes

Versions: 3

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

module Orchestration
  module Services
    module Mongo
      class Healthcheck
        include HealthcheckBase

        def initialize(env)
          @configuration = Configuration.new(env)
        end

        def connection_errors
          [::Mongo::Error::NoServerAvailable]
        end

        def connect
          # REVIEW: For some reason this is extremely slow. Worth trying
          # to see if there's a faster way to fail.
          Mongoid.load_configuration(@configuration.settings)
          !Mongoid.default_client.database_names.empty?
        end

        private

        def clients
          return Mongoid.sessions if Mongoid.respond_to?(:sessions)

          Mongoid.clients
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orchestration-0.2.2 lib/orchestration/services/mongo/healthcheck.rb
orchestration-0.2.1 lib/orchestration/services/mongo/healthcheck.rb
orchestration-0.2.0 lib/orchestration/services/mongo/healthcheck.rb