switch_gear 0.2.0 → 0.3.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: 6790aad189ffd50ac181d5e5e75fb5bf97e34d4c
4
- data.tar.gz: 9486ddff0840167fa1e62ad3f9c63a4ff8d0d90e
3
+ metadata.gz: d860f1e83ea49673a968bfe20c82dd0b2d310b6e
4
+ data.tar.gz: 15576db4b4034256d20c6cbc2d86f2216aaeb533
5
5
  SHA512:
6
- metadata.gz: 124441bce6d533ef404e3cdae2f6278182be8586bf069373e3c3ac377ede0a705fe7b408850b21245ac0338c00e4e40f6d42209eed795ad7c397971b95feb095
7
- data.tar.gz: 75807a66c3c9b49e8e38cf083b24400a14d60b432bab458407575d0cb714a82473a028dd3ff2d9042aa178d649cad4796767abcd69f824ad80caaa2530406602
6
+ metadata.gz: fbac051207bf2c2b0b58a1a8e8e67d474b26b5d345d42bf07f44fbc304cd288a2c1b865f8eb2a2766031aeec4af031395d15cc741292598c44be6db7ae5f4f49
7
+ data.tar.gz: f6558321c36a0f14635da33cbe41c8df08eb9b0cf00603ffab0f8439521320eea6129dca048261295dbd190c715530543f5651563a931bda8c78869a01bd2c24
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  .ruby-version
11
11
  Gemfile.lock
12
12
  *.swp
13
+ tags
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
55
55
  ## Enforcement
56
56
 
57
57
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at anthony.ross@validic.com. All
58
+ reported by contacting the project team at anthony DOT s DOT ross [AT] gmail. All
59
59
  complaints will be reviewed and investigated and will result in a response that
60
60
  is deemed necessary and appropriate to the circumstances. The project team is
61
61
  obligated to maintain confidentiality with regard to the reporter of an incident.
data/README.md CHANGED
@@ -24,7 +24,7 @@ And then execute:
24
24
 
25
25
  #### In Memory
26
26
 
27
- Here's an example of how you could use the breaker while making routine calls to a third party service such as Twitter:
27
+ Here is an example of how you could use the breaker while making routine calls to a third party service such as Twitter:
28
28
 
29
29
  ```ruby
30
30
  require 'switch_gear/circuit_breaker'
@@ -94,18 +94,21 @@ end
94
94
 
95
95
  You need 2 additional parameters(compared to the `Memory` adapter), they are defined as such:
96
96
 
97
- - `client` - an instance of a `Redis` client. This gem does not have a hard dependency on a particular redis client but for testing I've used [redis-rb](https://github.com/redis/redis-rb). Whatever you pass in here simply has to implement a few redis commands such as `sadd`, `del`, `smembers`, `get` and `set`. The client will ensure these exist before the breaker can be instantiated.
97
+ - `client` - an instance of a `Redis` client. This gem does not have a hard dependency on a particular redis client but for testing I've used [redis-rb](https://github.com/redis/redis-rb). Whatever you pass in here simply has to implement a few redis commands. The client will ensure these exist before the breaker can be instantiated.
98
98
  - `namespace` - A unique name that will be used across servers to sync `state` and `failures`. I'd recommend `class_name:some_method` or whatever is special about what's being invoked in the `circuit`.
99
99
 
100
100
  #### Roll Your Own Circuit Breaker
101
101
 
102
- The goal of this project is to help you implement a circuit breaker pattern and be agnostic to the persistence layer. I did it in memory and in redis both as working implementations to make the gem usable out of the box. There are other in memory data stores that would work really well with this and so you can easily implement your own.
102
+ The goal of this project is to help you implement a circuit breaker pattern and be agnostic to the persistence layer. I did it in memory and in redis both as working implementations to make the gem usable out of the box. There are other persitence stores that would work really well with this and you can roll your own simply by including the mixin.
103
103
 
104
104
  ```ruby
105
- class MyPreferredAdapter
105
+ class MyPreferredStore
106
106
  include SwitchGear::CircuitBreaker
107
107
  end
108
108
  ```
109
+ ## Sidekiq
110
+
111
+ I've [written a middleware](https://github.com/allcentury/switch_gear_sidekiq-middleware) for use with Sidekiq.
109
112
 
110
113
  ## Forthcoming
111
114
 
@@ -0,0 +1,127 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: SwitchGear
8
+
9
+ &mdash; Documentation by YARD 0.9.8
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "SwitchGear";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (S)</a> &raquo;
40
+
41
+
42
+ <span class="title">SwitchGear</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: SwitchGear
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/switch_gear.rb<span class="defines">,<br />
82
+ lib/switch_gear/version.rb,<br /> lib/switch_gear/circuit_breaker.rb,<br /> lib/switch_gear/circuit_breaker/redis.rb,<br /> lib/switch_gear/circuit_breaker/memory.rb,<br /> lib/switch_gear/circuit_breaker/failure.rb,<br /> lib/switch_gear/circuit_breaker/open_error.rb</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Defined Under Namespace</h2>
89
+ <p class="children">
90
+
91
+
92
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="SwitchGear/CircuitBreaker.html" title="SwitchGear::CircuitBreaker (module)">CircuitBreaker</a></span>
93
+
94
+
95
+
96
+
97
+ </p>
98
+
99
+ <h2>Constant Summary</h2>
100
+ <dl class="constants">
101
+
102
+ <dt id="VERSION-constant" class="">VERSION =
103
+
104
+ </dt>
105
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.2.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
106
+
107
+ </dl>
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ </div>
118
+
119
+ <div id="footer">
120
+ Generated on Fri May 26 06:53:24 2017 by
121
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
122
+ 0.9.8 (ruby-2.4.0).
123
+ </div>
124
+
125
+ </div>
126
+ </body>
127
+ </html>
@@ -0,0 +1,1004 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: SwitchGear::CircuitBreaker
8
+
9
+ &mdash; Documentation by YARD 0.9.8
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "SwitchGear::CircuitBreaker";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../SwitchGear.html" title="SwitchGear (module)">SwitchGear</a></span></span>
41
+ &raquo;
42
+ <span class="title">CircuitBreaker</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: SwitchGear::CircuitBreaker
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dl>
78
+ <dt>Included in:</dt>
79
+ <dd><span class='object_link'><a href="CircuitBreaker/Memory.html" title="SwitchGear::CircuitBreaker::Memory (class)">Memory</a></span>, <span class='object_link'><a href="CircuitBreaker/Redis.html" title="SwitchGear::CircuitBreaker::Redis (class)">Redis</a></span></dd>
80
+ </dl>
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/switch_gear/circuit_breaker.rb<span class="defines">,<br />
87
+ lib/switch_gear/circuit_breaker/redis.rb,<br /> lib/switch_gear/circuit_breaker/memory.rb,<br /> lib/switch_gear/circuit_breaker/failure.rb,<br /> lib/switch_gear/circuit_breaker/open_error.rb</span>
88
+ </dd>
89
+ </dl>
90
+
91
+ </div>
92
+
93
+ <h2>Defined Under Namespace</h2>
94
+ <p class="children">
95
+
96
+
97
+
98
+
99
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="CircuitBreaker/Failure.html" title="SwitchGear::CircuitBreaker::Failure (class)">Failure</a></span>, <span class='object_link'><a href="CircuitBreaker/Memory.html" title="SwitchGear::CircuitBreaker::Memory (class)">Memory</a></span>, <span class='object_link'><a href="CircuitBreaker/OpenError.html" title="SwitchGear::CircuitBreaker::OpenError (class)">OpenError</a></span>, <span class='object_link'><a href="CircuitBreaker/Redis.html" title="SwitchGear::CircuitBreaker::Redis (class)">Redis</a></span>
100
+
101
+
102
+ </p>
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <h2>
112
+ Instance Method Summary
113
+ <small><a href="#" class="summary_toggle">collapse</a></small>
114
+ </h2>
115
+
116
+ <ul class="summary">
117
+
118
+ <li class="public ">
119
+ <span class="summary_signature">
120
+
121
+ <a href="#add_failure-instance_method" title="#add_failure (instance method)">#<strong>add_failure</strong>(failure) &#x21d2; void </a>
122
+
123
+
124
+
125
+ </span>
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+ <span class="summary_desc"><div class='inline'></div></span>
136
+
137
+ </li>
138
+
139
+
140
+ <li class="public ">
141
+ <span class="summary_signature">
142
+
143
+ <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(*args) &#x21d2; Void, SwitchGear::CircuitBreaker::Open </a>
144
+
145
+
146
+
147
+ </span>
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+ <span class="summary_desc"><div class='inline'>
158
+ <p>Calls the circuit proc/lambda if the circuit is closed or half-open.</p>
159
+ </div></span>
160
+
161
+ </li>
162
+
163
+
164
+ <li class="public ">
165
+ <span class="summary_signature">
166
+
167
+ <a href="#closed%3F-instance_method" title="#closed? (instance method)">#<strong>closed?</strong> &#x21d2; Boolean </a>
168
+
169
+
170
+
171
+ </span>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ <span class="summary_desc"><div class='inline'>
182
+ <p>Whether the circuit is closed.</p>
183
+ </div></span>
184
+
185
+ </li>
186
+
187
+
188
+ <li class="public ">
189
+ <span class="summary_signature">
190
+
191
+ <a href="#failure_count-instance_method" title="#failure_count (instance method)">#<strong>failure_count</strong> &#x21d2; Integer </a>
192
+
193
+
194
+
195
+ </span>
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+ <span class="summary_desc"><div class='inline'>
206
+ <p>The count of current failures.</p>
207
+ </div></span>
208
+
209
+ </li>
210
+
211
+
212
+ <li class="public ">
213
+ <span class="summary_signature">
214
+
215
+ <a href="#failures-instance_method" title="#failures (instance method)">#<strong>failures</strong> &#x21d2; Array&lt;SwitchGear::CircuitBreaker::Failure&gt; </a>
216
+
217
+
218
+
219
+ </span>
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+ <span class="summary_desc"><div class='inline'>
230
+ <p>A list of current failures.</p>
231
+ </div></span>
232
+
233
+ </li>
234
+
235
+
236
+ <li class="public ">
237
+ <span class="summary_signature">
238
+
239
+ <a href="#failures=-instance_method" title="#failures= (instance method)">#<strong>failures=</strong>(failure) &#x21d2; void </a>
240
+
241
+
242
+
243
+ </span>
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+ <span class="summary_desc"><div class='inline'></div></span>
254
+
255
+ </li>
256
+
257
+
258
+ <li class="public ">
259
+ <span class="summary_signature">
260
+
261
+ <a href="#half_open%3F-instance_method" title="#half_open? (instance method)">#<strong>half_open?</strong> &#x21d2; Boolean </a>
262
+
263
+
264
+
265
+ </span>
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+ <span class="summary_desc"><div class='inline'>
276
+ <p>Whether the circuit is half-open.</p>
277
+ </div></span>
278
+
279
+ </li>
280
+
281
+
282
+ <li class="public ">
283
+ <span class="summary_signature">
284
+
285
+ <a href="#open%3F-instance_method" title="#open? (instance method)">#<strong>open?</strong> &#x21d2; Boolean </a>
286
+
287
+
288
+
289
+ </span>
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ <span class="summary_desc"><div class='inline'>
300
+ <p>Whether the circuit is open.</p>
301
+ </div></span>
302
+
303
+ </li>
304
+
305
+
306
+ <li class="public ">
307
+ <span class="summary_signature">
308
+
309
+ <a href="#state-instance_method" title="#state (instance method)">#<strong>state</strong> &#x21d2; Symbol </a>
310
+
311
+
312
+
313
+ </span>
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+ <span class="summary_desc"><div class='inline'><ul><li>
324
+ <p>either :open, :closed, :half-open.</p>
325
+ </li></ul>
326
+ </div></span>
327
+
328
+ </li>
329
+
330
+
331
+ <li class="public ">
332
+ <span class="summary_signature">
333
+
334
+ <a href="#state=-instance_method" title="#state= (instance method)">#<strong>state=</strong>(state) &#x21d2; void </a>
335
+
336
+
337
+
338
+ </span>
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+ <span class="summary_desc"><div class='inline'></div></span>
349
+
350
+ </li>
351
+
352
+
353
+ </ul>
354
+
355
+
356
+
357
+
358
+ <div id="instance_method_details" class="method_details_list">
359
+ <h2>Instance Method Details</h2>
360
+
361
+
362
+ <div class="method_details first">
363
+ <h3 class="signature first" id="add_failure-instance_method">
364
+
365
+ #<strong>add_failure</strong>(failure) &#x21d2; <tt>void</tt>
366
+
367
+
368
+
369
+
370
+
371
+ </h3><div class="docstring">
372
+ <div class="discussion">
373
+ <p class="note returns_void">This method returns an undefined value.</p>
374
+
375
+ </div>
376
+ </div>
377
+ <div class="tags">
378
+ <p class="tag_title">Parameters:</p>
379
+ <ul class="param">
380
+
381
+ <li>
382
+
383
+ <span class='name'>failure</span>
384
+
385
+
386
+ <span class='type'>(<tt><span class='object_link'><a href="CircuitBreaker/Failure.html" title="SwitchGear::CircuitBreaker::Failure (class)">SwitchGear::CircuitBreaker::Failure</a></span></tt>)</span>
387
+
388
+
389
+
390
+ &mdash;
391
+ <div class='inline'>
392
+ <p>a list of failures</p>
393
+ </div>
394
+
395
+ </li>
396
+
397
+ </ul>
398
+
399
+
400
+ </div><table class="source_code">
401
+ <tr>
402
+ <td>
403
+ <pre class="lines">
404
+
405
+
406
+ 52
407
+ 53
408
+ 54</pre>
409
+ </td>
410
+ <td>
411
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 52</span>
412
+
413
+ <span class='kw'>def</span> <span class='id identifier rubyid_add_failure'>add_failure</span><span class='lparen'>(</span><span class='id identifier rubyid_failure'>failure</span><span class='rparen'>)</span>
414
+ <span class='id identifier rubyid_must_implement'>must_implement</span><span class='lparen'>(</span><span class='symbol'>:add_failure</span><span class='rparen'>)</span>
415
+ <span class='kw'>end</span></pre>
416
+ </td>
417
+ </tr>
418
+ </table>
419
+ </div>
420
+
421
+ <div class="method_details ">
422
+ <h3 class="signature " id="call-instance_method">
423
+
424
+ #<strong>call</strong>(*args) &#x21d2; <tt>Void</tt>, <tt>SwitchGear::CircuitBreaker::Open</tt>
425
+
426
+
427
+
428
+
429
+
430
+ </h3><div class="docstring">
431
+ <div class="discussion">
432
+
433
+ <p>Calls the circuit proc/lambda if the circuit is closed or half-open.</p>
434
+
435
+
436
+ </div>
437
+ </div>
438
+ <div class="tags">
439
+ <p class="tag_title">Parameters:</p>
440
+ <ul class="param">
441
+
442
+ <li>
443
+
444
+ <span class='name'>args</span>
445
+
446
+
447
+ <span class='type'>(<tt>Array&lt;Object&gt;</tt>)</span>
448
+
449
+
450
+
451
+ &mdash;
452
+ <div class='inline'>
453
+ <p>Any number of Objects to be called with the circuit block.</p>
454
+ </div>
455
+
456
+ </li>
457
+
458
+ </ul>
459
+
460
+ <p class="tag_title">Returns:</p>
461
+ <ul class="return">
462
+
463
+ <li>
464
+
465
+
466
+ <span class='type'>(<tt>Void</tt>, <tt>SwitchGear::CircuitBreaker::Open</tt>)</span>
467
+
468
+
469
+
470
+ &mdash;
471
+ <div class='inline'>
472
+ <p>No usable return value if successful, but will raise an error if
473
+ failure_limit is reached or if the circuit is open</p>
474
+ </div>
475
+
476
+ </li>
477
+
478
+ </ul>
479
+ <p class="tag_title">Raises:</p>
480
+ <ul class="raise">
481
+
482
+ <li>
483
+
484
+
485
+ <span class='type'>(<tt><span class='object_link'><a href="CircuitBreaker/OpenError.html" title="SwitchGear::CircuitBreaker::OpenError (class)">OpenError</a></span></tt>)</span>
486
+
487
+
488
+
489
+ </li>
490
+
491
+ </ul>
492
+
493
+ </div><table class="source_code">
494
+ <tr>
495
+ <td>
496
+ <pre class="lines">
497
+
498
+
499
+ 13
500
+ 14
501
+ 15
502
+ 16
503
+ 17</pre>
504
+ </td>
505
+ <td>
506
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 13</span>
507
+
508
+ <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
509
+ <span class='id identifier rubyid_check_reset_timeout'>check_reset_timeout</span>
510
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="CircuitBreaker/OpenError.html" title="SwitchGear::CircuitBreaker::OpenError (class)">OpenError</a></span></span> <span class='kw'>if</span> <span class='id identifier rubyid_open?'>open?</span>
511
+ <span class='id identifier rubyid_do_run'>do_run</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_circuit'>circuit</span><span class='rparen'>)</span>
512
+ <span class='kw'>end</span></pre>
513
+ </td>
514
+ </tr>
515
+ </table>
516
+ </div>
517
+
518
+ <div class="method_details ">
519
+ <h3 class="signature " id="closed?-instance_method">
520
+
521
+ #<strong>closed?</strong> &#x21d2; <tt>Boolean</tt>
522
+
523
+
524
+
525
+
526
+
527
+ </h3><div class="docstring">
528
+ <div class="discussion">
529
+
530
+ <p>Returns Whether the circuit is closed</p>
531
+
532
+
533
+ </div>
534
+ </div>
535
+ <div class="tags">
536
+
537
+ <p class="tag_title">Returns:</p>
538
+ <ul class="return">
539
+
540
+ <li>
541
+
542
+
543
+ <span class='type'>(<tt>Boolean</tt>)</span>
544
+
545
+
546
+
547
+ &mdash;
548
+ <div class='inline'>
549
+ <p>Whether the circuit is closed</p>
550
+ </div>
551
+
552
+ </li>
553
+
554
+ </ul>
555
+
556
+ </div><table class="source_code">
557
+ <tr>
558
+ <td>
559
+ <pre class="lines">
560
+
561
+
562
+ 30
563
+ 31
564
+ 32</pre>
565
+ </td>
566
+ <td>
567
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 30</span>
568
+
569
+ <span class='kw'>def</span> <span class='id identifier rubyid_closed?'>closed?</span>
570
+ <span class='id identifier rubyid_state'>state</span> <span class='op'>==</span> <span class='symbol'>:closed</span>
571
+ <span class='kw'>end</span></pre>
572
+ </td>
573
+ </tr>
574
+ </table>
575
+ </div>
576
+
577
+ <div class="method_details ">
578
+ <h3 class="signature " id="failure_count-instance_method">
579
+
580
+ #<strong>failure_count</strong> &#x21d2; <tt>Integer</tt>
581
+
582
+
583
+
584
+
585
+
586
+ </h3><div class="docstring">
587
+ <div class="discussion">
588
+
589
+ <p>Returns The count of current failures</p>
590
+
591
+
592
+ </div>
593
+ </div>
594
+ <div class="tags">
595
+
596
+ <p class="tag_title">Returns:</p>
597
+ <ul class="return">
598
+
599
+ <li>
600
+
601
+
602
+ <span class='type'>(<tt>Integer</tt>)</span>
603
+
604
+
605
+
606
+ &mdash;
607
+ <div class='inline'>
608
+ <p>The count of current failures</p>
609
+ </div>
610
+
611
+ </li>
612
+
613
+ </ul>
614
+
615
+ </div><table class="source_code">
616
+ <tr>
617
+ <td>
618
+ <pre class="lines">
619
+
620
+
621
+ 20
622
+ 21
623
+ 22</pre>
624
+ </td>
625
+ <td>
626
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 20</span>
627
+
628
+ <span class='kw'>def</span> <span class='id identifier rubyid_failure_count'>failure_count</span>
629
+ <span class='id identifier rubyid_failures'>failures</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
630
+ <span class='kw'>end</span></pre>
631
+ </td>
632
+ </tr>
633
+ </table>
634
+ </div>
635
+
636
+ <div class="method_details ">
637
+ <h3 class="signature " id="failures-instance_method">
638
+
639
+ #<strong>failures</strong> &#x21d2; <tt>Array&lt;<span class='object_link'><a href="CircuitBreaker/Failure.html" title="SwitchGear::CircuitBreaker::Failure (class)">SwitchGear::CircuitBreaker::Failure</a></span>&gt;</tt>
640
+
641
+
642
+
643
+
644
+
645
+ </h3><div class="docstring">
646
+ <div class="discussion">
647
+
648
+ <p>Returns a list of current failures</p>
649
+
650
+
651
+ </div>
652
+ </div>
653
+ <div class="tags">
654
+
655
+ <p class="tag_title">Returns:</p>
656
+ <ul class="return">
657
+
658
+ <li>
659
+
660
+
661
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="CircuitBreaker/Failure.html" title="SwitchGear::CircuitBreaker::Failure (class)">SwitchGear::CircuitBreaker::Failure</a></span>&gt;</tt>)</span>
662
+
663
+
664
+
665
+ &mdash;
666
+ <div class='inline'>
667
+ <p>a list of current failures</p>
668
+ </div>
669
+
670
+ </li>
671
+
672
+ </ul>
673
+
674
+ </div><table class="source_code">
675
+ <tr>
676
+ <td>
677
+ <pre class="lines">
678
+
679
+
680
+ 40
681
+ 41
682
+ 42</pre>
683
+ </td>
684
+ <td>
685
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 40</span>
686
+
687
+ <span class='kw'>def</span> <span class='id identifier rubyid_failures'>failures</span>
688
+ <span class='id identifier rubyid_must_implement'>must_implement</span><span class='lparen'>(</span><span class='symbol'>:failures</span><span class='rparen'>)</span>
689
+ <span class='kw'>end</span></pre>
690
+ </td>
691
+ </tr>
692
+ </table>
693
+ </div>
694
+
695
+ <div class="method_details ">
696
+ <h3 class="signature " id="failures=-instance_method">
697
+
698
+ #<strong>failures=</strong>(failure) &#x21d2; <tt>void</tt>
699
+
700
+
701
+
702
+
703
+
704
+ </h3><div class="docstring">
705
+ <div class="discussion">
706
+ <p class="note returns_void">This method returns an undefined value.</p>
707
+
708
+ </div>
709
+ </div>
710
+ <div class="tags">
711
+ <p class="tag_title">Parameters:</p>
712
+ <ul class="param">
713
+
714
+ <li>
715
+
716
+ <span class='name'>failure</span>
717
+
718
+
719
+ <span class='type'>(<tt>Array&lt;<span class='object_link'><a href="CircuitBreaker/Failure.html" title="SwitchGear::CircuitBreaker::Failure (class)">SwitchGear::CircuitBreaker::Failure</a></span>&gt;</tt>)</span>
720
+
721
+
722
+
723
+ &mdash;
724
+ <div class='inline'>
725
+ <p>a list of failures</p>
726
+ </div>
727
+
728
+ </li>
729
+
730
+ </ul>
731
+
732
+
733
+ </div><table class="source_code">
734
+ <tr>
735
+ <td>
736
+ <pre class="lines">
737
+
738
+
739
+ 46
740
+ 47
741
+ 48</pre>
742
+ </td>
743
+ <td>
744
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 46</span>
745
+
746
+ <span class='kw'>def</span> <span class='id identifier rubyid_failures='>failures=</span><span class='lparen'>(</span><span class='id identifier rubyid_failure'>failure</span><span class='rparen'>)</span>
747
+ <span class='id identifier rubyid_must_implement'>must_implement</span><span class='lparen'>(</span><span class='symbol'>:failures=</span><span class='rparen'>)</span>
748
+ <span class='kw'>end</span></pre>
749
+ </td>
750
+ </tr>
751
+ </table>
752
+ </div>
753
+
754
+ <div class="method_details ">
755
+ <h3 class="signature " id="half_open?-instance_method">
756
+
757
+ #<strong>half_open?</strong> &#x21d2; <tt>Boolean</tt>
758
+
759
+
760
+
761
+
762
+
763
+ </h3><div class="docstring">
764
+ <div class="discussion">
765
+
766
+ <p>Returns Whether the circuit is half-open</p>
767
+
768
+
769
+ </div>
770
+ </div>
771
+ <div class="tags">
772
+
773
+ <p class="tag_title">Returns:</p>
774
+ <ul class="return">
775
+
776
+ <li>
777
+
778
+
779
+ <span class='type'>(<tt>Boolean</tt>)</span>
780
+
781
+
782
+
783
+ &mdash;
784
+ <div class='inline'>
785
+ <p>Whether the circuit is half-open</p>
786
+ </div>
787
+
788
+ </li>
789
+
790
+ </ul>
791
+
792
+ </div><table class="source_code">
793
+ <tr>
794
+ <td>
795
+ <pre class="lines">
796
+
797
+
798
+ 35
799
+ 36
800
+ 37</pre>
801
+ </td>
802
+ <td>
803
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 35</span>
804
+
805
+ <span class='kw'>def</span> <span class='id identifier rubyid_half_open?'>half_open?</span>
806
+ <span class='id identifier rubyid_state'>state</span> <span class='op'>==</span> <span class='symbol'>:half_open</span>
807
+ <span class='kw'>end</span></pre>
808
+ </td>
809
+ </tr>
810
+ </table>
811
+ </div>
812
+
813
+ <div class="method_details ">
814
+ <h3 class="signature " id="open?-instance_method">
815
+
816
+ #<strong>open?</strong> &#x21d2; <tt>Boolean</tt>
817
+
818
+
819
+
820
+
821
+
822
+ </h3><div class="docstring">
823
+ <div class="discussion">
824
+
825
+ <p>Returns Whether the circuit is open</p>
826
+
827
+
828
+ </div>
829
+ </div>
830
+ <div class="tags">
831
+
832
+ <p class="tag_title">Returns:</p>
833
+ <ul class="return">
834
+
835
+ <li>
836
+
837
+
838
+ <span class='type'>(<tt>Boolean</tt>)</span>
839
+
840
+
841
+
842
+ &mdash;
843
+ <div class='inline'>
844
+ <p>Whether the circuit is open</p>
845
+ </div>
846
+
847
+ </li>
848
+
849
+ </ul>
850
+
851
+ </div><table class="source_code">
852
+ <tr>
853
+ <td>
854
+ <pre class="lines">
855
+
856
+
857
+ 25
858
+ 26
859
+ 27</pre>
860
+ </td>
861
+ <td>
862
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 25</span>
863
+
864
+ <span class='kw'>def</span> <span class='id identifier rubyid_open?'>open?</span>
865
+ <span class='id identifier rubyid_state'>state</span> <span class='op'>==</span> <span class='symbol'>:open</span>
866
+ <span class='kw'>end</span></pre>
867
+ </td>
868
+ </tr>
869
+ </table>
870
+ </div>
871
+
872
+ <div class="method_details ">
873
+ <h3 class="signature " id="state-instance_method">
874
+
875
+ #<strong>state</strong> &#x21d2; <tt>Symbol</tt>
876
+
877
+
878
+
879
+
880
+
881
+ </h3><div class="docstring">
882
+ <div class="discussion">
883
+
884
+ <p>Returns - either :open, :closed, :half-open</p>
885
+
886
+
887
+ </div>
888
+ </div>
889
+ <div class="tags">
890
+
891
+ <p class="tag_title">Returns:</p>
892
+ <ul class="return">
893
+
894
+ <li>
895
+
896
+
897
+ <span class='type'>(<tt>Symbol</tt>)</span>
898
+
899
+
900
+
901
+ &mdash;
902
+ <div class='inline'><ul><li>
903
+ <p>either :open, :closed, :half-open</p>
904
+ </li></ul>
905
+ </div>
906
+
907
+ </li>
908
+
909
+ </ul>
910
+
911
+ </div><table class="source_code">
912
+ <tr>
913
+ <td>
914
+ <pre class="lines">
915
+
916
+
917
+ 57
918
+ 58
919
+ 59</pre>
920
+ </td>
921
+ <td>
922
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 57</span>
923
+
924
+ <span class='kw'>def</span> <span class='id identifier rubyid_state'>state</span>
925
+ <span class='id identifier rubyid_must_implement'>must_implement</span><span class='lparen'>(</span><span class='symbol'>:state</span><span class='rparen'>)</span>
926
+ <span class='kw'>end</span></pre>
927
+ </td>
928
+ </tr>
929
+ </table>
930
+ </div>
931
+
932
+ <div class="method_details ">
933
+ <h3 class="signature " id="state=-instance_method">
934
+
935
+ #<strong>state=</strong>(state) &#x21d2; <tt>void</tt>
936
+
937
+
938
+
939
+
940
+
941
+ </h3><div class="docstring">
942
+ <div class="discussion">
943
+ <p class="note returns_void">This method returns an undefined value.</p>
944
+
945
+ </div>
946
+ </div>
947
+ <div class="tags">
948
+ <p class="tag_title">Parameters:</p>
949
+ <ul class="param">
950
+
951
+ <li>
952
+
953
+ <span class='name'>state</span>
954
+
955
+
956
+ <span class='type'>(<tt>Symbol</tt>)</span>
957
+
958
+
959
+
960
+ &mdash;
961
+ <div class='inline'><ul><li>
962
+ <p>either :open, :closed, :half-open</p>
963
+ </li></ul>
964
+ </div>
965
+
966
+ </li>
967
+
968
+ </ul>
969
+
970
+
971
+ </div><table class="source_code">
972
+ <tr>
973
+ <td>
974
+ <pre class="lines">
975
+
976
+
977
+ 63
978
+ 64
979
+ 65</pre>
980
+ </td>
981
+ <td>
982
+ <pre class="code"><span class="info file"># File 'lib/switch_gear/circuit_breaker.rb', line 63</span>
983
+
984
+ <span class='kw'>def</span> <span class='id identifier rubyid_state='>state=</span><span class='lparen'>(</span><span class='id identifier rubyid_state'>state</span><span class='rparen'>)</span>
985
+ <span class='id identifier rubyid_must_implement'>must_implement</span><span class='lparen'>(</span><span class='symbol'>:state=</span><span class='rparen'>)</span>
986
+ <span class='kw'>end</span></pre>
987
+ </td>
988
+ </tr>
989
+ </table>
990
+ </div>
991
+
992
+ </div>
993
+
994
+ </div>
995
+
996
+ <div id="footer">
997
+ Generated on Fri May 26 06:53:24 2017 by
998
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
999
+ 0.9.8 (ruby-2.4.0).
1000
+ </div>
1001
+
1002
+ </div>
1003
+ </body>
1004
+ </html>