rsolr-cloud-lw 1.1.0 → 1.1.1

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: df8d5a6f0c5dc0b14ed1447b055ed562cf7862cd7ed9c3912bb6f662242159d0
4
- data.tar.gz: 70260d0cb6d8565f5f55e393dc31e12fd3609e714ed59d4de52929315f17b00d
3
+ metadata.gz: 338ad609dcb7e15e561b387d16a77e1399bc3458d81366643e3a045e6c841253
4
+ data.tar.gz: 1c019ca48edb2f7745d079b08ff5ee3f8a4ebaf26e8aaf9d2fa031c87cf278e5
5
5
  SHA512:
6
- metadata.gz: 16c47852e31bcb22e5c90e396faa04b7b5914959bf1fcc6115ddc4ffa24746859bce28b51e54e48edc8642454381c4906ae69732900d3ee1e1817a91023e42d4
7
- data.tar.gz: 05222647c3f9e320452b8445cde36b96f63dc220d72577b27131f459ca181660a92f617fbe7c57886d5275856c10bee7c511f1a7232d3ba390adde7225d8e6be
6
+ metadata.gz: ac748b9607791d83566af7c1f8403daa62576ce858fee1a5804748ff5b9032d693b06a6d7564fce984d24fc07d14d8eaed1fb004473d1a2abf9e868fefdf4699
7
+ data.tar.gz: 6d0142a79f555b4e294de0502bee029ddf613deb56bf05fb96bc08cac31317d9af5ede1acad67c33853b5516a8dd7ded47f5d35242f748e86f6c2c2a9fc025e8
@@ -7,9 +7,10 @@ module RSolr
7
7
  ZNODE_LIVE_NODES = '/live_nodes'.freeze
8
8
  ZNODE_CLUSTER_PROPS = '/clusterprops.json'.freeze
9
9
 
10
- def initialize(zk)
10
+ def initialize(zk, options = {})
11
11
  super()
12
12
  @zk = zk
13
+ @options = options
13
14
  init_url_scheme
14
15
  init_live_node_watcher
15
16
  end
@@ -52,11 +53,22 @@ module RSolr
52
53
  synchronize do
53
54
  @live_nodes = []
54
55
  @zk.children(ZNODE_LIVE_NODES, watch: true).each do |node|
55
- # "/" between host_and_port part of url and context is replaced with "_" in ZK
56
- @live_nodes << @url_scheme + '://' + node.tr('_', '/')
56
+ @live_nodes << node_url(node)
57
57
  end
58
58
  end
59
59
  end
60
+
61
+ def node_url(node)
62
+ # "/" between host_and_port part of url and context is replaced with "_" in ZK
63
+ u = node.tr('_', '/')
64
+ # add basic auth credentials in the form of "http://user:pass@host"
65
+ if @options[:user] && @options[:password]
66
+ u = @options[:user] + ':' + @options[:password] + '@' + u
67
+ end
68
+ # add url scheme
69
+ u = @url_scheme + '://' + u
70
+ u
71
+ end
60
72
  end
61
73
  end
62
74
  end
@@ -1,5 +1,5 @@
1
1
  module Rsolr
2
2
  module Cloud
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.1.1'.freeze
4
4
  end
5
5
  end
@@ -4,6 +4,7 @@ RSpec.describe RSolr::Cloud::Connection do
4
4
  before do
5
5
  @zk_in_solr = ZK.new
6
6
  delete_with_children(@zk_in_solr, '/live_nodes')
7
+ delete_with_children(@zk_in_solr, '/clusterprops.json')
7
8
  wait_until(10) do
8
9
  !@zk_in_solr.exists?('/live_nodes')
9
10
  end
@@ -67,6 +68,15 @@ RSpec.describe RSolr::Cloud::Connection do
67
68
  'http://192.168.1.24:8983/solr'].sort)
68
69
  end
69
70
 
71
+ it 'should use basic auth.' do
72
+ @subject = RSolr::Cloud::Connection.new @zk, :user => 'user1', :password => 'pass1'
73
+ expect(@subject.instance_variable_get(:@live_nodes).sort).to eq(
74
+ ['http://user1:pass1@192.168.1.21:8983/solr',
75
+ 'http://user1:pass1@192.168.1.22:8983/solr',
76
+ 'http://user1:pass1@192.168.1.23:8983/solr',
77
+ 'http://user1:pass1@192.168.1.24:8983/solr'].sort)
78
+ end
79
+
70
80
  it 'should obey url scheme.' do
71
81
  @zk_in_solr.create('/clusterprops.json', '{"urlScheme": "https"}')
72
82
  @subject = RSolr::Cloud::Connection.new @zk
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsolr-cloud-lw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Kimura
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-24 00:00:00.000000000 Z
12
+ date: 2019-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement