search_flip 2.1.0.beta1 → 2.1.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 906fc0c71acae9c0ad7dd8b3089c78cbe73388348e43cd25470eb7289502652a
4
- data.tar.gz: 5c45894fd491152c08cd3c5e39ca5bafa94e321ae81166dc7d3ce0012fa834ba
3
+ metadata.gz: 6b3740c9ca1f4b34538a0302d4efc92afb12ee845d1b534241070ade3255b4dd
4
+ data.tar.gz: afb51d3e77ef804e3487da46a8f5db33a9d5baa9dd17337afb09fa4874b710e3
5
5
  SHA512:
6
- metadata.gz: 2abdc760a6a104b242bd1147d4bf5629996c6e58b89b4a364b2b21c75daae0a3b57165577e75450b80fa965611b54a4680dd10deba7a22d3021381c7d893fa37
7
- data.tar.gz: 81e2c3887da0f55653a60cbea327a068964b42acd30427b274f05e2091a5f30c67a7af0bbdac1ab38a29a31c97c4048a23c0ea265c5bb44c2b8a4ef7db8577d5
6
+ metadata.gz: 96e43715270ac96cd15933a6e2243c9f61dec661abe6b70e1aba93d411a7ebaa19c528a6c9f5d11950babd48f144afef06a4b5be29d91bc2d820bc014b81e951
7
+ data.tar.gz: be195c055a264206dd2a85657fd8c874d8e09661e6bb9d39f0fbc80f1c30cda3ce006082540c739d00eadecbf0f4e2fd68805e4c0099393bbe153986864a67a3
data/README.md CHANGED
@@ -549,11 +549,13 @@ To use multiple Elasticsearch clusters, specify a connection within your
549
549
  indices:
550
550
 
551
551
  ```ruby
552
+ MyConnection = SearchFlip::Connection.new(base_url: "http://elasticsearch.host:9200")
553
+
552
554
  class MyIndex
553
555
  include SearchFlip::Index
554
556
 
555
557
  def self.connection
556
- @connection ||= SearchFlip::Connection.new(base_url: "http://elasticsearch.host:9200")
558
+ MyConnection
557
559
  end
558
560
  end
559
561
  ```
@@ -17,6 +17,7 @@ module SearchFlip
17
17
  @base_url = options[:base_url] || SearchFlip::Config[:base_url]
18
18
  @http_client = options[:http_client] || SearchFlip::HTTPClient.new
19
19
  @bulk_limit = options[:bulk_limit] || SearchFlip::Config[:bulk_limit]
20
+ @version_mutex = Mutex.new
20
21
  end
21
22
 
22
23
  # Queries and returns the ElasticSearch version used.
@@ -27,7 +28,9 @@ module SearchFlip
27
28
  # @return [String] The ElasticSearch version
28
29
 
29
30
  def version
30
- @version ||= http_client.headers(accept: "application/json").get("#{base_url}/").parse["version"]["number"]
31
+ @version_mutex.synchronize do
32
+ @version ||= http_client.headers(accept: "application/json").get("#{base_url}/").parse["version"]["number"]
33
+ end
31
34
  end
32
35
 
33
36
  # Queries and returns the ElasticSearch cluster health.
@@ -42,6 +42,8 @@ module SearchFlip
42
42
  # CommentIndex.range(:created_at, gt: Time.now - 7.days)
43
43
 
44
44
  module Index
45
+ ConnectionMutex = Mutex.new
46
+
45
47
  def self.included(base)
46
48
  base.extend ClassMethods
47
49
  end
@@ -159,7 +161,7 @@ module SearchFlip
159
161
  yield record
160
162
  end
161
163
  else
162
- (scope.respond_to?(:each) ? scope : Array(scope)).each do |record|
164
+ (scope.respond_to?(:each) && !scope.is_a?(SearchFlip::Result) ? scope : Array(scope)).each do |record|
163
165
  yield record
164
166
  end
165
167
  end
@@ -636,7 +638,9 @@ module SearchFlip
636
638
  # @return [SearchFlip::Connection] The connection
637
639
 
638
640
  def connection
639
- @connection ||= SearchFlip::Connection.new(base_url: SearchFlip::Config[:base_url])
641
+ ConnectionMutex.synchronize do
642
+ @connection ||= SearchFlip::Connection.new(base_url: SearchFlip::Config[:base_url])
643
+ end
640
644
  end
641
645
  end
642
646
  end
@@ -1,5 +1,5 @@
1
1
 
2
2
  module SearchFlip
3
- VERSION = "2.1.0.beta1"
3
+ VERSION = "2.1.0.beta2"
4
4
  end
5
5
 
data/lib/search_flip.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require "forwardable"
3
3
  require "http"
4
4
  require "hashie"
5
+ require "thread"
5
6
  require "oj"
6
7
  require "set"
7
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.beta1
4
+ version: 2.1.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-07 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord