locker 0.3.1 → 0.3.2

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: 26ef04b820465aabae3bae6882ce4e26c10903be
4
- data.tar.gz: da0895652026efb9c039587b23f83a82e5e0f6f6
3
+ metadata.gz: 1623bce6a4448a47c0f7244284c37a68b40a9fb3
4
+ data.tar.gz: c4b81eada8d4cf229eda2854308da3f7a13d13d3
5
5
  SHA512:
6
- metadata.gz: e22f69322a8b8a22ec6c05a011a2a2824aede763357f673f34e08dc6d43584c103b24ac780f1df56d812814ce3768c2aa2c2b098fc2014f9639ec65d6852da4f
7
- data.tar.gz: 0ebb808afb8b0e6442c8b9f7ad3360bf9771e41a26f4156cc3b8973a21ce735d4be62edacabed4cb52d035972f4e69a0e6360534eae9314855f8f488e3b6cd9f
6
+ metadata.gz: eb8b6a9996aeacd61f13101c8c84d0becdddd62caaaa2672f926934fb2f7ea2c5c403d50ff8ceb756c321bf2d9d77eaac2bc4c81ef9fc66bb220e8fa135543e7
7
+ data.tar.gz: 127921d87034603b81452a88bf578913f5b6cdaac722fd9bb8f05b43ba16c6e7ab05eab3c395b1297f72b8f6f097b538623342c357d36e8be3ca1c8b7b5d6135
data/README.md CHANGED
@@ -27,7 +27,7 @@ Suppose you have a process running on a server that continually performs a task.
27
27
  #### Code (lib/new_feed_checker.rb)
28
28
 
29
29
  ```ruby
30
- while true
30
+ loop do
31
31
  FeedChecker.check_for_new_feeds
32
32
  end
33
33
  ```
@@ -49,7 +49,7 @@ This would work fantastic, so long as `FeedChecker.check_for_new_feeds` is safe
49
49
  ```ruby
50
50
  Locker.run("new-feed-checker") do # One server will get the lock
51
51
  # Only one server will get here
52
- while true
52
+ loop do
53
53
  FeedChecker.check_for_new_feeds
54
54
  end
55
55
  end # Lock is released at this point
@@ -68,7 +68,7 @@ This is great! We've made sure that only one server can run the code at any give
68
68
  ```ruby
69
69
  Locker.run("new-feed-checker", :blocking => true) do
70
70
  # Only one server will get here at a time. The other server will patiently wait.
71
- while true
71
+ loop do
72
72
  FeedChecker.check_for_new_feeds
73
73
  end
74
74
  end # Lock is released at this point
@@ -150,7 +150,7 @@ end
150
150
  In our use we've settled on a common pattern, one that lets us distribute the load of our processes between our application and/or utility servers while making sure we have no single point of failure. This means that no single server going down (except the database) will stop the code from executing. Continuing from the code above, we'll use the example of the RSS/Atom feed checker, `FeedChecker.check_for_new_feeds`. To improve on the previous examples, we'll make the code rotate among our servers, so over a long enough time period each server will have spent an equal amount of time running the task.
151
151
 
152
152
  ```ruby
153
- while true
153
+ loop do
154
154
  Locker.run("new-feed-checker", :blocking => true) do
155
155
  FeedChecker.check_for_new_feeds
156
156
  end
@@ -33,7 +33,7 @@ class Locker
33
33
  connection = ActiveRecord::Base.connection_pool.checkout
34
34
  connection.transaction :requires_new => true do
35
35
  while !get(connection) && @blocking
36
- sleep 0.5
36
+ sleep 0.005
37
37
  end
38
38
 
39
39
  if @locked
@@ -1,3 +1,3 @@
1
1
  class Locker
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Sutton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-11 00:00:00.000000000 Z
12
+ date: 2017-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project: locker
117
- rubygems_version: 2.4.6
117
+ rubygems_version: 2.4.8
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Locker is a locking mechanism for limiting the concurrency of ruby code using