Sha256: 48bc2682cee2d3ceed95c368046d85bf793abcd979f851c60f1e2b22b541364d

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

require 'elasticsearch'
require 'ditty/services/logger'

module ProxES
  module Services
    module ES
      def client
        @client ||= Elasticsearch::Client.new(
          url: ENV['ELASTICSEARCH_URL'],
          adapter: :net_http_persistent,
          transport_options: {
            ssl: {
              verify: ENV['SSL_VERIFY_NONE'].to_i != 1,
              cert_store: ssl_store
            }
          },
          logger: Ditty::Services::Logger.instance
        )
      end

      def ssl_store
        store = OpenSSL::X509::Store.new
        store.set_default_paths
        store
      end

      def conn
        client.transport.connections.first.connection
      end

      def cluster_health(level = 'cluster')
        client.cluster.health level: level
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
proxes-0.9.2 lib/proxes/services/es.rb
proxes-0.9.1 lib/proxes/services/es.rb
proxes-0.9.0 lib/proxes/services/es.rb