insque 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -14
- data/lib/generators/insque/templates/insque.erb +1 -1
- data/lib/insque/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01104bacbddad2fd85675e9f242aea346d3101c9
|
4
|
+
data.tar.gz: a3debfd746d82c059abf4f6423f1aa9bb2f6baf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d2e64b82459b0268286ec5c9d2e9dd5209f58e99dbd8ac70f0bb734886e7f607b6cd0c4a2e3e40efd79552629e2791193fda349432f26c9cd0267f72b418a1c
|
7
|
+
data.tar.gz: 4240f9fb0a74cae2a5bf7b416b8ecc506d8fad44bf83562af008ecbc97d1c51bb505c4436dbf882c02f9edfc8cd31d3e9de5cc8ed42be999c3ca3d7ed0642246
|
data/README.md
CHANGED
@@ -41,29 +41,66 @@ There is an easy way to use insque as background jobs processing. You can use `s
|
|
41
41
|
To start recieving messages you need to:
|
42
42
|
|
43
43
|
1. Create handler method in Insque module. First part of handler name is the name of the message sender.
|
44
|
-
```ruby
|
45
|
-
def somesender_message_name message
|
46
|
-
|
47
|
-
end
|
48
|
-
```
|
44
|
+
```ruby
|
45
|
+
def somesender_message_name message
|
46
|
+
#TODO: Handle message somehow
|
47
|
+
end
|
48
|
+
```
|
49
49
|
|
50
50
|
2. Call `listen` method in some background process or rake task:
|
51
|
-
```ruby
|
52
|
-
Insque.listen
|
53
|
-
```
|
51
|
+
```ruby
|
52
|
+
Insque.listen
|
53
|
+
```
|
54
54
|
|
55
55
|
or just run `bundle exec rake insque:listener` from your console.
|
56
56
|
|
57
57
|
3. Call `janitor` method in some background process or rake task. Janitor will reissue failed messages or report error if message fails again. Janitor treats message as failed if it was not processed for an hour after broadcast or reissue.
|
58
|
+
```ruby
|
59
|
+
Insque.janitor
|
60
|
+
```
|
61
|
+
|
62
|
+
or just run `bundle exec rake insque:janitor` from your console.
|
63
|
+
|
64
|
+
### Slow Queue and send_later
|
65
|
+
|
66
|
+
Insque can be used for processing slow tasks in background. Slow tasks created with send_later method call of any ActiveRecord model:
|
58
67
|
```ruby
|
59
|
-
|
68
|
+
User.send_later :some_slow_method
|
60
69
|
```
|
70
|
+
and processed by a special slow listener:
|
71
|
+
```ruby
|
72
|
+
Insque.slow_listen
|
73
|
+
```
|
74
|
+
there is matching slow janitor as well:
|
75
|
+
```ruby
|
76
|
+
Insque.slow_janitor
|
77
|
+
```
|
78
|
+
### insque:run
|
61
79
|
|
62
|
-
|
80
|
+
There is a simple way to run all insque workers, both regular and slow in a single multi-threaded process:
|
81
|
+
```ruby
|
82
|
+
bundle exec rake insque:run
|
83
|
+
```
|
84
|
+
|
85
|
+
### RedisCluster support
|
86
|
+
|
87
|
+
To make insque run on Redis Cluster add this line to your application's `Gemfile`:
|
88
|
+
|
89
|
+
gem 'redis_cluster'
|
90
|
+
|
91
|
+
and change `redis.yml` file accordingly:
|
92
|
+
|
93
|
+
production:
|
94
|
+
- host: cluster_host1
|
95
|
+
port: 1234
|
96
|
+
- host: cluster_host2
|
97
|
+
port: 1234
|
98
|
+
- host: cluster_host3
|
99
|
+
port: 1234
|
63
100
|
|
64
101
|
### Daemonizing
|
65
102
|
|
66
|
-
If you want to run insque
|
103
|
+
If you want to run insque as a daemon consider using [foreman](https://github.com/ddollar/foreman) for this.
|
67
104
|
|
68
105
|
If you deploy with capistrano you may want to try a version of foreman with build in capistrano support.
|
69
106
|
|
@@ -78,8 +115,8 @@ Install it:
|
|
78
115
|
|
79
116
|
Create `Procfile`:
|
80
117
|
|
81
|
-
|
82
|
-
|
118
|
+
insque: bundle exec rake insque:run
|
119
|
+
|
83
120
|
|
84
121
|
Run foreman from your console:
|
85
122
|
|
@@ -88,7 +125,7 @@ Run foreman from your console:
|
|
88
125
|
For production use modify your capistrano deploy script somewhat like this:
|
89
126
|
|
90
127
|
set :default_environment, {'PATH' => "/sbin:$PATH"} # Optional. Useful if you get errors because start or restart command not found
|
91
|
-
set :foreman_concurrency, "\"
|
128
|
+
set :foreman_concurrency, "\"insque=1\"" # How many processes of each type do you want
|
92
129
|
require 'foreman/capistrano'
|
93
130
|
|
94
131
|
after "deploy", "foreman:export" # Export Procfile as a set of upstart jobs
|
data/lib/insque/version.rb
CHANGED