later 0.1.1 → 0.1.2
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.
- data/README.md +28 -30
- data/lib/later/version.rb +1 -1
- data/lib/later.rb +3 -3
- metadata +2 -2
data/README.md
CHANGED
@@ -2,64 +2,48 @@
|
|
2
2
|
|
3
3
|
[**Later**](erol.github.com/later) is a Redis-backed event scheduling library for Ruby.
|
4
4
|
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'later'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install later
|
18
|
-
|
19
5
|
## Usage
|
20
6
|
|
21
|
-
|
7
|
+
Later allows you to manage schedule sets:
|
22
8
|
|
23
9
|
require 'later'
|
24
10
|
|
25
|
-
Later allows you to manage multiple schedule sets:
|
26
|
-
|
27
11
|
Later[:reservations]
|
28
12
|
Later[:appointments]
|
29
13
|
|
30
|
-
The schedule sets are referenced based on the default Redis instance. If you need a schedule set which resides on a different Redis instance, you can pass a [Nest](github.com/soveran/nest) object.
|
14
|
+
The schedule sets are referenced based on the default Redis instance. If you need a schedule set which resides on a different Redis instance, you can pass a [Nest](github.com/soveran/nest) object when referencing a schedule set.
|
31
15
|
|
32
|
-
|
16
|
+
redis = Redis.new host: host, port: port
|
33
17
|
key = Nest.new :reservations, redis
|
34
18
|
|
35
19
|
Later[key]
|
36
20
|
|
37
21
|
Setting an event schedule is simple:
|
38
22
|
|
39
|
-
|
23
|
+
Later[key].set 'my-unique-event', Time.now + 60
|
40
24
|
|
41
|
-
And can be
|
25
|
+
And can be reschedule with equal simplicity:
|
42
26
|
|
43
|
-
|
27
|
+
Later[key].set 'my-unique-event', Time.now + 120
|
44
28
|
|
45
29
|
An event schedule can also be unset:
|
46
30
|
|
47
|
-
|
31
|
+
Later[key].unset 'my-unique-event'
|
48
32
|
|
49
|
-
Note that event names should be unique in the scope of
|
33
|
+
Note that event names should be unique in the scope of its schedule set.
|
50
34
|
|
51
35
|
### Workers
|
52
36
|
|
53
37
|
Workers are Ruby processes that run forever. They allow you to process event schedules in the background:
|
54
38
|
|
55
|
-
|
56
|
-
|
39
|
+
require 'later'
|
40
|
+
|
57
41
|
Later[:reservations].each do |event|
|
58
42
|
# Do something with the event.
|
59
43
|
end
|
60
|
-
|
44
|
+
|
61
45
|
# This line is never reached.
|
62
|
-
|
46
|
+
|
63
47
|
If for some reason, a worker has to stop itself from running:
|
64
48
|
|
65
49
|
Later[:reservations].each do |event|
|
@@ -67,9 +51,23 @@ If for some reason, a worker has to stop itself from running:
|
|
67
51
|
|
68
52
|
Later[:reservations].stop if stop?
|
69
53
|
end
|
70
|
-
|
54
|
+
|
71
55
|
# This line is reached if stop? is true.
|
72
56
|
|
57
|
+
## Installation
|
58
|
+
|
59
|
+
Add this line to your application's Gemfile:
|
60
|
+
|
61
|
+
gem 'later'
|
62
|
+
|
63
|
+
And then execute:
|
64
|
+
|
65
|
+
$ bundle
|
66
|
+
|
67
|
+
Or install it yourself as:
|
68
|
+
|
69
|
+
$ gem install later
|
70
|
+
|
73
71
|
## Contributing
|
74
72
|
|
75
73
|
1. Fork it
|
@@ -77,4 +75,4 @@ If for some reason, a worker has to stop itself from running:
|
|
77
75
|
3. Create tests and make them pass ( `rake test` )
|
78
76
|
4. Commit your changes ( `git commit -am 'Added some feature'` )
|
79
77
|
5. Push to the branch ( `git push origin my-new-feature` )
|
80
|
-
6. Create a new Pull Request
|
78
|
+
6. Create a new Pull Request
|
data/lib/later/version.rb
CHANGED
data/lib/later.rb
CHANGED
@@ -54,9 +54,9 @@ module Later
|
|
54
54
|
schedule.zremrangebyscore '-inf', time
|
55
55
|
ids = schedule.redis.exec.first
|
56
56
|
|
57
|
-
key.redis.multi
|
58
|
-
|
59
|
-
|
57
|
+
key.redis.multi do
|
58
|
+
ids.each { |id| queue.lpush id }
|
59
|
+
end
|
60
60
|
|
61
61
|
event = queue.brpoplpush(backup, 1)
|
62
62
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: later
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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
|
+
date: 2012-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|