cellect-client 1.0.1 → 1.1.0

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
  SHA1:
3
- metadata.gz: bbe514c3f6a707c05dd2ced856393161be2f04d1
4
- data.tar.gz: ea1ec754a475c3601ca6a205ecd6e031fb895132
3
+ metadata.gz: a3e274e1943008aaed80c4fe3108524e957503d1
4
+ data.tar.gz: 154f4715e5f8b565e753e3b7a6cee28ff2276f26
5
5
  SHA512:
6
- metadata.gz: d9b76e88177b1c902e72bcada00180575d0e038c9a678d3e093ef57549043490282a233aae4735b18bdaffd9b94daf4aeab97dc587fa9e193c0355c96437e5ea
7
- data.tar.gz: 11cf6f27299e1a413ec0d842afb2830fa65683c463e7263d9bd35a155d7b502e48a65ee8ab57b47b0e39bb8755a68c0e49e1035112c487b93b84af87ca7c6d59
6
+ metadata.gz: d63309ac6b9d1b493e5f09d7e267343e0122efe414d1bc1dd96d7e098fa79f916beb6650c3233d0507fc1f37de2469b52d0c81099431b181949822d04865c747
7
+ data.tar.gz: 47b0afae6ea956ad89bb377d8bbc621b0fb68499310cfbad28894718b97bc502b9d40ee52bb6194eda6b434434ee02b4039d804e44124c17f886336180d84173
@@ -9,6 +9,11 @@ module Cellect
9
9
  attr_accessor :connection, :_node_set
10
10
  end
11
11
 
12
+ # Disabled with lib/cellect/testing.rb
13
+ def self.mock_zookeeper?
14
+ false
15
+ end
16
+
12
17
  # Sets up the set of server nodes
13
18
  def self.node_set(zk_url=nil)
14
19
  self._node_set ||= NodeSet.supervise(zk_url)
@@ -29,11 +34,7 @@ module Cellect
29
34
  node_set.nodes.values.include? ip
30
35
  end
31
36
 
32
- if defined?(::Rails)
33
- require 'cellect/client/railtie'
34
- else
35
- Client.node_set
36
- Client.connection = Connection.pool size: ENV.fetch('CELLECT_POOL_SIZE', 100).to_i
37
- end
37
+ Client.node_set
38
+ Client.connection = Connection.pool size: ENV.fetch('CELLECT_POOL_SIZE', 100).to_i
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module Cellect
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cellect-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Parrish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-21 00:00:00.000000000 Z
11
+ date: 2015-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -199,7 +199,6 @@ files:
199
199
  - lib/cellect/client.rb
200
200
  - lib/cellect/client/connection.rb
201
201
  - lib/cellect/client/node_set.rb
202
- - lib/cellect/client/railtie.rb
203
202
  - lib/cellect/node_set.rb
204
203
  - lib/cellect/testing.rb
205
204
  - lib/cellect/version.rb
@@ -1,53 +0,0 @@
1
- module Cellect
2
- module Client
3
- class ConfigurationError < StandardError; end;
4
-
5
- # Allow YAML configuration from config/cellect.yml
6
- #
7
- # development:
8
- # zk_url: localhost:2181
9
- # pool_size: 50
10
- class CellectRailtie < Rails::Railtie
11
- initializer 'cellect.connect_to_zookeeper' do
12
- ensure_config_file
13
- config = YAML.load_file config_file
14
- ensure_config_environment config
15
- config = config[Rails.env].symbolize_keys
16
- ensure_config_url config
17
- connect_zookeeper config if load_zookeeper
18
- end
19
-
20
- private
21
-
22
- def config_file
23
- Rails.root.join 'config/cellect.yml'
24
- end
25
-
26
- def ensure_config_file
27
- return if File.exists?(config_file)
28
- raise ConfigurationError.new 'No configuration file found. Create config/cellect.yml first'
29
- end
30
-
31
- def ensure_config_environment(yaml)
32
- return if yaml[Rails.env].is_a?(Hash)
33
- raise ConfigurationError.new "No configuration for #{ Rails.env } found"
34
- end
35
-
36
- def ensure_config_url(hash)
37
- return if hash[:zk_url].present?
38
- raise ConfigurationError.new "No Zookeeper URL provided for #{ Rails.env } environment"
39
- end
40
-
41
- def connect_zookeeper(config)
42
- Client.node_set config[:zk_url]
43
- Client.connection = Connection.pool size: config.fetch(:pool_size, 100)
44
- end
45
-
46
- def load_zookeeper
47
- !Client.mock_zookeeper?
48
- rescue NoMethodError
49
- true
50
- end
51
- end
52
- end
53
- end