rate_limited_scheduler 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. data/lib/rate_limited_scheduler.rb +5 -4
  2. metadata +3 -3
@@ -17,14 +17,15 @@ class RateLimitedScheduler
17
17
  config.default_interval = 1
18
18
  end
19
19
 
20
- def initialize(bucket, constraint)
20
+ def initialize(bucket, constraint, redis_options={})
21
21
  # default: 5 executions per second
22
22
  constraint[:threshold] ||= @@configuration.default_threshold
23
23
  constraint[:interval] ||= @@configuration.default_interval
24
-
24
+
25
25
  @bucket = bucket
26
+ @redis_options = redis_options
26
27
  @constraint = constraint
27
- @redis = Redis::Namespace.new(:ratelimiter, { :redis => Redis.new })
28
+ @redis = Redis::Namespace.new(:ratelimiter, { :redis => Redis.new(@redis_options) })
28
29
 
29
30
  @redis.multi do
30
31
  @redis.del(@bucket)
@@ -58,7 +59,7 @@ class RateLimitedScheduler
58
59
  end
59
60
 
60
61
  def wait_for_execution_handle
61
- subscriber = Redis::Namespace.new(:ratelimiter, { :redis => Redis.new })
62
+ subscriber = Redis::Namespace.new(:ratelimiter, { :redis => Redis.new(@redis_options) })
62
63
 
63
64
  subscriber.subscribe(:new_execution_handle_available) do |on|
64
65
  execution_handle = get_execution_handle(subscriber)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rate_limited_scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-17 00:00:00.000000000 Z
12
+ date: 2013-01-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This rate-limited scheduler is made for requests to APIs with sensitive,
15
15
  time-critical access restrictions which means that even limits with short time intervals
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  version: '0'
42
42
  requirements: []
43
43
  rubyforge_project:
44
- rubygems_version: 1.8.23
44
+ rubygems_version: 1.8.24
45
45
  signing_key:
46
46
  specification_version: 3
47
47
  summary: A Redis-based rate-limited scheduler for requests to APIs with sensitive