strangler 1.0.4 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f5f337398a5f03935eb2c80ba55c9402b4be22a
4
- data.tar.gz: 7fc55a6dd28ac44bd8e20304e155aaa0d7e777ec
3
+ metadata.gz: b0da5cc26b362a7a0890633a4672bf0f460d46fa
4
+ data.tar.gz: 8c8f6b5f364c75756f48f483da512cc91157edad
5
5
  SHA512:
6
- metadata.gz: b116467388625cd3c38b378dbd13dfdf3f664e3f7a77b13fcaf7c74b40701d597fa53ccc6c4dbf8fa5d9f33ffe814a7ad3222c899a2088e5542e1a30ca035c23
7
- data.tar.gz: 00ddc6ccd8a6b2d04f16251a22f050fa50ff3281d2bb30c4dfdfc1af732caccccf3e48f8962e2995058c3ab6ed104a3c1c1fb7316b4392fb515cce28f783bd2e
6
+ metadata.gz: 52f524d70f0a683950934a4903f71a7bd9a0c8c64f0f59f8439236bdc2f7daf7ca351b60e70e626a665e433b435df635840f1015f4f95f2c5a3e58dc2756c747
7
+ data.tar.gz: d0a278b08362f878bfe80e83888ac569b5f41eadc27731b58d3bf907633e88cde3c9a7e5ebead3d3afb3e018351d5bb82496ec3143c74caaec467c637fb1a726
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- throttler (0.1.0)
4
+ strangler (1.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -16,7 +16,7 @@ DEPENDENCIES
16
16
  bundler (~> 1.16)
17
17
  minitest (~> 5.0)
18
18
  rake (~> 10.0)
19
- throttler!
19
+ strangler!
20
20
 
21
21
  BUNDLED WITH
22
22
  1.16.1
data/README.md CHANGED
@@ -33,6 +33,8 @@ Typical usage is as follows:
33
33
 
34
34
  This ensures (by sleeping the current thread) that a call to the external API does not occur until at least 1.5 seconds after the previous call completed.
35
35
 
36
+ If an exception occurs within the block and is handled outside of it, (e.g. a network timeout) the time when the exception occurred is assumed to be the completion time of the operation. If you need to include the exception handling time, the exception handler must be placed inside the block.
37
+
36
38
  Note that if you are writing a Rails app with multiple processes (e.g. by using Passenger), you will need to somehow ensure that all rate limited API calls are made by the same process.
37
39
 
38
40
  The specifications of the rate limits for APIs are often ambiguous: does a rate limit of 1 call per second allow a call that takes 2 seconds to overlap with another call after the first second? Strangler takes the most conservative interpretation possible - calls cannot overlap and and the delay argument given to the Strangler constructor is the minimum time between the start of one block execution and the end of the previous block execution.
@@ -41,7 +43,7 @@ The specifications of the rate limits for APIs are often ambiguous: does a rate
41
43
 
42
44
  This gem is designed to handle the simple use case of calling an API (possibly from multiple threads) which has a rate limit.
43
45
 
44
- If you need a more sophisticated strategy (e.g. to perform useful work rather than sleeping, or to avoid potential thread starvation by the thread scheduler) then you should probably be using a different gem.
46
+ If you need a more sophisticated strategy (e.g. to perform useful work rather than sleeping, or to avoid potential thread starvation by the thread scheduler)then you should probably be using a different gem.
45
47
 
46
48
  Sorry about the gem name: the good names were already taken.
47
49
 
data/lib/strangler.rb CHANGED
@@ -2,7 +2,7 @@ require 'thread'
2
2
 
3
3
  # Limit calls to an API by sleeping
4
4
  class Strangler
5
- VERSION = "1.0.4"
5
+ VERSION = "1.0.5"
6
6
 
7
7
 
8
8
  # Set the minimum delay between calls
@@ -25,8 +25,11 @@ class Strangler
25
25
  sleep doze_time
26
26
  end
27
27
  end
28
- yield # Do the stuff
29
- @next_call = Time.now + @minimum_delay_secs
28
+ begin
29
+ yield # Do the stuff
30
+ ensure
31
+ @next_call = Time.now + @minimum_delay_secs
32
+ end
30
33
  end
31
34
  end
32
35
  end
data/strangler.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["mbell@albionresearch.com"]
11
11
 
12
12
  spec.summary = %q{Throttle executions of a block}
13
- spec.description = %q{Throttle executions of a block, e.g. to meet an API rate limit}
13
+ spec.description = %q{Throttle executions of a block, e.g. to meet an external API rate limit}
14
14
  spec.homepage = "https://www.github.com/m-z-b/strangler"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- description: Throttle executions of a block, e.g. to meet an API rate limit
55
+ description: Throttle executions of a block, e.g. to meet an external API rate limit
56
56
  email:
57
57
  - mbell@albionresearch.com
58
58
  executables: []