nutcracker 0.2.4.10 → 0.2.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjdhMzQwMTk4ZjkyODliOTQ3MTVkOGY5YTZhNjM0NWJlNzAzYzA1Yw==
5
+ data.tar.gz: !binary |-
6
+ NTkyNDQ1ZjJlOWFmNTA3YTNkYjllN2EwOTE0Mjk2MjY3NTA2ZGIxYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODAwNTgzYWFkMzZkMjhlYWU4YjBlZmIwOTUyMjE3ODU5NzA4YTYwMWI3YjIw
10
+ ODFmMzBlYzBhNmYzNjIxYWY2MDAzNjdiMDUzNTM2M2ZjMmZkNzllYjY1YzMx
11
+ ODRjODUyZmIwMDc0N2I2ZWQ1MjI2ZWNhZTVjNTAxNDU4N2U1YWU=
12
+ data.tar.gz: !binary |-
13
+ NDY2ZmZlOWQzYTdiMTA5ZGM4ZGJiYjRjZjdkYWQwYjUzMWQzOWVlZDJjMzVk
14
+ N2JkNGZjMTEwM2E5ODA3ODliNWU3YzE0NTA0YTU1NGM2ZjY1M2VhN2UwYjJm
15
+ NWYyY2YwOWI5NzQ5YTY2OWJhZWZlNmZjZWUxNGEyYmQ3MWU5MGU=
data/lib/nutcracker.rb CHANGED
@@ -13,7 +13,7 @@ module Nutcracker
13
13
  def self.start options
14
14
  Nutcracker::Wrapper.new(options).start
15
15
  end
16
-
16
+
17
17
  # Connect to a running instance of Nutcracker ( see {Wrapper#initialize} )
18
18
  # @return [Wrapper] Nutcracker process wrapper
19
19
  # @example
@@ -21,7 +21,7 @@ module Nutcracker
21
21
  def self.attach options
22
22
  Nutcracker::Wrapper.new options.merge attached: true
23
23
  end
24
-
24
+
25
25
  # Returns the Nutcracker executable path that is embeded with the gem
26
26
  def self.executable
27
27
  File.expand_path("../../ext/nutcracker/src/nutcracker", __FILE__)
@@ -43,36 +43,36 @@ module Nutcracker
43
43
  def initialize options
44
44
  @options = validate defaults.merge options
45
45
  end
46
-
46
+
47
47
  # launching the Nutcracker service
48
48
  def start *args
49
49
  return self if attached? or running?
50
50
  @pid = ::Process.spawn Nutcracker.executable, *command
51
- timeout(60) { sleep 1 until running? }
51
+ timeout(5) { sleep 0.1 until running? }
52
52
  Kernel.at_exit { kill if running? }
53
53
  self
54
54
  end
55
-
55
+
56
56
  # Returns the current running status
57
57
  def running?
58
58
  stats.any?
59
59
  end
60
-
60
+
61
61
  # Returns true if the current instance was initialize with the attached flag
62
62
  def attached?
63
63
  @options[:attached]
64
64
  end
65
-
65
+
66
66
  # Stops the Nutcracker service
67
67
  def stop
68
68
  sig :TERM
69
69
  end
70
-
70
+
71
71
  # Kills the Nutcracker service
72
72
  def kill
73
73
  sig :KILL
74
74
  end
75
-
75
+
76
76
  # Wait for the process to exit
77
77
  def join
78
78
  attached? ? sleep : (running! and ::Process.waitpid2 pid)
@@ -87,8 +87,8 @@ module Nutcracker
87
87
  def use plugin, *args
88
88
  Nutcracker.const_get(plugin.to_s.capitalize).start(self,*args)
89
89
  end
90
-
91
- # Returns hash with server and node statistics
90
+
91
+ # Returns hash with server and node statistics
92
92
  # See example.json @ project root to get details about the structure
93
93
  def overview
94
94
  data = { :clusters => [], :config => config }
@@ -99,9 +99,9 @@ module Nutcracker
99
99
  data[cluster_name] = cluster_data
100
100
  next
101
101
  end
102
-
102
+
103
103
  next unless redis? cluster_name # skip memcached clusters
104
-
104
+
105
105
  aliases = node_aliases cluster_name
106
106
  cluster = { nodes: [], name: cluster_name }
107
107
  cluster_data.each do |node, node_value|
@@ -122,21 +122,21 @@ module Nutcracker
122
122
  end
123
123
  data
124
124
  end
125
-
125
+
126
126
  # Check if a given cluster name was configure as Redis
127
127
  def redis? cluster
128
128
  config[cluster]["redis"] rescue false
129
129
  end
130
-
130
+
131
131
  # https://github.com/twitter/twemproxy/blob/master/notes/recommendation.md#node-names-for-consistent-hashing
132
132
  def node_aliases cluster
133
133
  Hash[config[cluster]["servers"].map(&:split).each {|o| o[0]=o[0].split(":")[0..1].join(":")}.map(&:reverse)]
134
134
  end
135
-
135
+
136
136
  # Returns hash with information about a given Redis
137
137
  def redis_info url
138
138
  begin
139
- redis = Redis.connect(url: url)
139
+ redis = Redis.connect(url: url)
140
140
  info = redis.info
141
141
  db_size = redis.dbsize
142
142
  max_memory = redis.config(:get, 'maxmemory')['maxmemory'].to_i
@@ -144,7 +144,7 @@ module Nutcracker
144
144
  rescue Exception
145
145
  return {}
146
146
  end
147
-
147
+
148
148
  {
149
149
  'connections' => info['connected_clients'].to_i,
150
150
  'used_memory' => info['used_memory'].to_f,
@@ -166,24 +166,24 @@ module Nutcracker
166
166
  end
167
167
 
168
168
  private
169
-
169
+
170
170
  def command
171
171
  ['-c', @options[:config_file],'-s',@options[:stats_port],*@options[:args]].map(&:to_s)
172
172
  end
173
-
173
+
174
174
  def defaults
175
175
  { :args => [],
176
176
  :config_file => 'conf/nutcracker.yaml',
177
177
  :stats_port => 22222,
178
178
  :attached => false}
179
179
  end
180
-
180
+
181
181
  def validate options
182
182
  options.tap { File.exists? options[:config_file] or raise "#{options[:config_file]} not found" }
183
183
  end
184
184
 
185
185
  def running!
186
- running? or raise RuntimeError, "Nutcracker isn't running..."
186
+ running? or raise RuntimeError, "Nutcracker isn't running..."
187
187
  end
188
188
 
189
189
  def sig term
@@ -1,3 +1,3 @@
1
1
  module Nutcracker
2
- VERSION = "0.2.4.10"
2
+ VERSION = "0.2.4.11"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nutcracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4.10
5
- prerelease:
4
+ version: 0.2.4.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - Eran Barak Levi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-11-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: minitest
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mocha
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: redis
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -218,30 +211,26 @@ files:
218
211
  - ext/nutcracker/src/proto/nc_redis.c
219
212
  homepage: http://www.kontera.com
220
213
  licenses: []
214
+ metadata: {}
221
215
  post_install_message:
222
216
  rdoc_options:
223
217
  - --no-private --protected lib/**/*.rb - README.md
224
218
  require_paths:
225
219
  - lib
226
220
  required_ruby_version: !ruby/object:Gem::Requirement
227
- none: false
228
221
  requirements:
229
222
  - - ! '>='
230
223
  - !ruby/object:Gem::Version
231
224
  version: 1.8.5
232
225
  required_rubygems_version: !ruby/object:Gem::Requirement
233
- none: false
234
226
  requirements:
235
227
  - - ! '>='
236
228
  - !ruby/object:Gem::Version
237
229
  version: '0'
238
- segments:
239
- - 0
240
- hash: 2623002414258179319
241
230
  requirements: []
242
231
  rubyforge_project: ruby-nutcracker
243
- rubygems_version: 1.8.25
232
+ rubygems_version: 2.1.9
244
233
  signing_key:
245
- specification_version: 3
234
+ specification_version: 4
246
235
  summary: Gem wrapper for Twitter's Nutcracker
247
236
  test_files: []