exponential_backoff 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0d9f69e3ee02f109cc36d53d44ec606e8d9d96a5
4
+ data.tar.gz: b5044042ab5d5415f9f7cd926462527a5d4d0f0a
5
+ SHA512:
6
+ metadata.gz: 45ae6ebb3749c20399bcf93bfb450a0509b49b3b8cbed6e11065124a1d3b128eb05da173064d0757b8ae4ddff19f425a638bb9ac8d79eed2efb995c266666d4b
7
+ data.tar.gz: 7d969904c3516891ef2bb20654c66139a1ce2319840646ddc06742034b8280437f44f0ac87d0440c72cf9f7c544b0e7f732676b52bc5ec3078ad9bb286811fbd
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Martin Manelli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ exponential_backoff
2
+ ===================
3
+
4
+ Simple Exponential Backoff
@@ -0,0 +1,20 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'exponential_backoff'
3
+ s.version = '0.1.0'
4
+ s.summary = 'Exponential Backoff'
5
+ s.description = 'Simple Exponential Backoff in Ruby'
6
+ s.author = 'Martin Manelli'
7
+ s.email = 'manelli.ml@gmail.com'
8
+ s.homepage = 'http://github.com/manelli/hippie'
9
+ s.license = 'MIT'
10
+ s.require_paths = ['lib']
11
+
12
+ s.files = Dir[
13
+ 'LICENSE',
14
+ 'README.md',
15
+ 'makefile',
16
+ 'lib/exponential_backoff.rb',
17
+ 'tests/exponential_backoff_test.rb',
18
+ 'exponential_backoff.gemspec'
19
+ ]
20
+ end
@@ -0,0 +1,23 @@
1
+ module ExponentialBackoff
2
+ RequestNotSucceded = Class.new(StandardError)
3
+
4
+ def self.try(max_tries, &block)
5
+ 1.upto max_tries do |n|
6
+ begin
7
+ return res = block.call
8
+ rescue => error
9
+ wait(n)
10
+ next
11
+ end
12
+ end
13
+ raise RequestNotSucceded
14
+ end
15
+
16
+ private
17
+
18
+ def self.wait(iteration)
19
+ seconds = rand(1..1000) * 0.001
20
+ waiting_time = (2**iteration + seconds).ceil
21
+ sleep(waiting_time)
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exponential_backoff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Martin Manelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple Exponential Backoff in Ruby
14
+ email: manelli.ml@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - exponential_backoff.gemspec
22
+ - lib/exponential_backoff.rb
23
+ homepage: http://github.com/manelli/hippie
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.4.2
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Exponential Backoff
47
+ test_files: []