fake_go_up 0.1.1 → 0.1.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 +37 -5
- data/lib/fake_go_up/version.rb +1 -1
- data/lib/fake_go_up.rb +11 -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: e09f267aa34d168abd3e05189699dbb8cef1e882
|
4
|
+
data.tar.gz: 05ff1d6d0b87654353df698e737a7a8131568652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79c2010a2e6cdbafdcbd7ad25a381e1ebe51a5c248a71d9a98ad9a5d18a1a831a09132e5d65e835851a9530d3e0225cac789a688c567201e202c58e0d3248c4
|
7
|
+
data.tar.gz: 66423a74413673a850449fa03ba2fec7013ec45bd77f2d5202c75ac5295dfb4bc070dde068df4e92e85dedc7835232708c8fa0821a09fc62ee0f7195a5962827
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# FakeGoUp
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fake_go_up`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
If you need add fake favor's count, you could use this gem。
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -22,7 +19,42 @@ Or install it yourself as:
|
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
you should init the redis before your app star, like this
|
23
|
+
```ruby
|
24
|
+
FakeGoUp.redis = $redis #$redis is your redis instance
|
25
|
+
```
|
26
|
+
|
27
|
+
then, you should define your own voter under `lib/voters`。such as `test_voter.rb`
|
28
|
+
each voter should do things as little as possible. each interval`s unit is at least 1 second.
|
29
|
+
it is simple,and it is not parallel !!!
|
30
|
+
```ruby
|
31
|
+
#lib/voters/test_voter.rb
|
32
|
+
class TestVoter < FakeGoUp
|
33
|
+
max_fake_count 20 #max fake count per interval, default is 20
|
34
|
+
interval 1 #seconds per interval
|
35
|
+
def process(item, fake_count)
|
36
|
+
#you should overwrite this func, and item is a active record project
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
then you should run a rake per 5-10 times, like this
|
42
|
+
```ruby
|
43
|
+
#lib/tasks/fake_go_up.rake
|
44
|
+
namespace :fake_go_up do
|
45
|
+
task :run => :environment do
|
46
|
+
FakeGoUp.run
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
`FakeGoUp.run` will never stop until all jobs finish. you should run a rake to check if there is new jobs. if there is a running fake_go_up, if will not star a new fake_go_up.
|
51
|
+
|
52
|
+
now `TestVoter` provide theses func
|
53
|
+
```
|
54
|
+
t = TestVoter.new
|
55
|
+
TestVoter.remain(t) # => the t`s remain fake count needs to add
|
56
|
+
TestVoter.running?(t) # => if the t`s fake_go_up is running?
|
57
|
+
```
|
26
58
|
|
27
59
|
## Development
|
28
60
|
|
data/lib/fake_go_up/version.rb
CHANGED
data/lib/fake_go_up.rb
CHANGED
@@ -25,7 +25,17 @@ module FakeGoUp
|
|
25
25
|
|
26
26
|
def _run
|
27
27
|
tasks = FakeGoUp::Task.subclasses.map(&:new)
|
28
|
-
|
28
|
+
running = true
|
29
|
+
|
30
|
+
Signal.trap("TERM") do
|
31
|
+
running = false
|
32
|
+
end
|
33
|
+
|
34
|
+
Signal.trap("QUIT") do
|
35
|
+
running = false
|
36
|
+
end
|
37
|
+
|
38
|
+
while running
|
29
39
|
all_finish = true
|
30
40
|
|
31
41
|
tasks.each do |task|
|