bushpig 0.1.9 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +17 -7
- data/gemset.nix +66 -13
- data/lib/bushpig.rb +9 -0
- data/lib/bushpig/client.rb +10 -5
- data/lib/bushpig/job.rb +9 -5
- data/lib/bushpig/server.rb +5 -1
- data/lib/bushpig/testing.rb +14 -0
- data/lib/bushpig/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50478f11ab72c719f2b8ef316866f3822370b9680bbf926b66ee6e981688057e
|
4
|
+
data.tar.gz: 7a5e2e7b548556b6484a8d2b5998cc5eb59b167023a972628c44a23646fe6cbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2f3d17d804d1de3e378274408c8109c9dd26895249624ed175ea3f2fcbb0ac52410931f5c0d09378306595c44060abe3bc2875737d95d84f04192d4dfe06b29
|
7
|
+
data.tar.gz: 588e4f398d33a51e15264b15709a45523f75a954f283d73317551e5f089a609bfdbd489f0c604eacd5c12136ca00edd6cf8a2a0cc44e35a72b1d25b214e19330
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bushpig (0.1.
|
4
|
+
bushpig (0.1.14)
|
5
5
|
connection_pool (~> 2.2)
|
6
6
|
json (>= 1.8)
|
7
7
|
redis (~> 3.3)
|
@@ -16,15 +16,23 @@ GEM
|
|
16
16
|
coderay (1.1.3)
|
17
17
|
connection_pool (2.2.5)
|
18
18
|
e2mmap (0.1.0)
|
19
|
+
io-wait (0.1.0)
|
19
20
|
jaro_winkler (1.5.4)
|
20
|
-
json (2.1
|
21
|
+
json (2.5.1)
|
21
22
|
kramdown (2.3.1)
|
22
23
|
rexml
|
23
24
|
kramdown-parser-gfm (1.1.0)
|
24
25
|
kramdown (~> 2.0)
|
25
26
|
method_source (1.0.0)
|
26
|
-
mini_portile2 (2.5.
|
27
|
-
|
27
|
+
mini_portile2 (2.5.2)
|
28
|
+
net-ftp (~> 0.1)
|
29
|
+
net-ftp (0.1.2)
|
30
|
+
net-protocol
|
31
|
+
time
|
32
|
+
net-protocol (0.1.1)
|
33
|
+
io-wait
|
34
|
+
timeout
|
35
|
+
nokogiri (1.11.6)
|
28
36
|
mini_portile2 (~> 2.5.0)
|
29
37
|
racc (~> 1.4)
|
30
38
|
parallel (1.20.1)
|
@@ -41,7 +49,7 @@ GEM
|
|
41
49
|
reverse_markdown (2.0.0)
|
42
50
|
nokogiri
|
43
51
|
rexml (3.2.5)
|
44
|
-
rubocop (1.
|
52
|
+
rubocop (1.15.0)
|
45
53
|
parallel (~> 1.10)
|
46
54
|
parser (>= 3.0.0.0)
|
47
55
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -50,10 +58,10 @@ GEM
|
|
50
58
|
rubocop-ast (>= 1.5.0, < 2.0)
|
51
59
|
ruby-progressbar (~> 1.7)
|
52
60
|
unicode-display_width (>= 1.4.0, < 3.0)
|
53
|
-
rubocop-ast (1.
|
61
|
+
rubocop-ast (1.7.0)
|
54
62
|
parser (>= 3.0.1.1)
|
55
63
|
ruby-progressbar (1.11.0)
|
56
|
-
solargraph (0.
|
64
|
+
solargraph (0.41.0)
|
57
65
|
backport (~> 1.1)
|
58
66
|
benchmark
|
59
67
|
bundler (>= 1.17.2)
|
@@ -69,6 +77,8 @@ GEM
|
|
69
77
|
yard (~> 0.9, >= 0.9.24)
|
70
78
|
thor (1.1.0)
|
71
79
|
tilt (2.0.10)
|
80
|
+
time (0.1.0)
|
81
|
+
timeout (0.1.1)
|
72
82
|
unicode-display_width (2.0.0)
|
73
83
|
yard (0.9.26)
|
74
84
|
|
data/gemset.nix
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
path = ./.;
|
187
187
|
type = "path";
|
188
188
|
};
|
189
|
-
version = "0.1.
|
189
|
+
version = "0.1.14";
|
190
190
|
};
|
191
191
|
coderay = {
|
192
192
|
groups = ["default" "development"];
|
@@ -367,6 +367,16 @@
|
|
367
367
|
};
|
368
368
|
version = "0.1.0";
|
369
369
|
};
|
370
|
+
io-wait = {
|
371
|
+
groups = ["default" "development"];
|
372
|
+
platforms = [];
|
373
|
+
source = {
|
374
|
+
remotes = ["https://rubygems.org"];
|
375
|
+
sha256 = "11zpcigndc11fkr2s6659d7nh1hj09zpmxlyqp9yq1mx76038s6w";
|
376
|
+
type = "gem";
|
377
|
+
};
|
378
|
+
version = "0.1.0";
|
379
|
+
};
|
370
380
|
jaro_winkler = {
|
371
381
|
groups = ["default" "development"];
|
372
382
|
platforms = [];
|
@@ -531,10 +541,10 @@
|
|
531
541
|
}];
|
532
542
|
source = {
|
533
543
|
remotes = ["https://rubygems.org"];
|
534
|
-
sha256 = "
|
544
|
+
sha256 = "0lrirj0gw420kw71bjjlqkqhqbrplla61gbv1jzgsz6bv90qr3ci";
|
535
545
|
type = "gem";
|
536
546
|
};
|
537
|
-
version = "2.1
|
547
|
+
version = "2.5.1";
|
538
548
|
};
|
539
549
|
kramdown = {
|
540
550
|
dependencies = ["rexml"];
|
@@ -569,14 +579,37 @@
|
|
569
579
|
version = "1.0.0";
|
570
580
|
};
|
571
581
|
mini_portile2 = {
|
582
|
+
dependencies = ["net-ftp"];
|
572
583
|
groups = ["default" "development"];
|
573
584
|
platforms = [];
|
574
585
|
source = {
|
575
586
|
remotes = ["https://rubygems.org"];
|
576
|
-
sha256 = "
|
587
|
+
sha256 = "0a2y04km3aciybk12yimkqn0ycrzy23iygl116n7addix9xdii3s";
|
577
588
|
type = "gem";
|
578
589
|
};
|
579
|
-
version = "2.5.
|
590
|
+
version = "2.5.2";
|
591
|
+
};
|
592
|
+
net-ftp = {
|
593
|
+
dependencies = ["net-protocol" "time"];
|
594
|
+
groups = ["default" "development"];
|
595
|
+
platforms = [];
|
596
|
+
source = {
|
597
|
+
remotes = ["https://rubygems.org"];
|
598
|
+
sha256 = "1gx09b00k454fgn7q41r9xs5j5v9qj8xhfxnm650cns1ywcmzkil";
|
599
|
+
type = "gem";
|
600
|
+
};
|
601
|
+
version = "0.1.2";
|
602
|
+
};
|
603
|
+
net-protocol = {
|
604
|
+
dependencies = ["io-wait" "timeout"];
|
605
|
+
groups = ["default" "development"];
|
606
|
+
platforms = [];
|
607
|
+
source = {
|
608
|
+
remotes = ["https://rubygems.org"];
|
609
|
+
sha256 = "1ivxcqwgnrqbp2y0zpxz64in9a2cx9q9b0fxb630c51a1jaq63yz";
|
610
|
+
type = "gem";
|
611
|
+
};
|
612
|
+
version = "0.1.1";
|
580
613
|
};
|
581
614
|
nokogiri = {
|
582
615
|
dependencies = ["mini_portile2" "racc"];
|
@@ -584,10 +617,10 @@
|
|
584
617
|
platforms = [];
|
585
618
|
source = {
|
586
619
|
remotes = ["https://rubygems.org"];
|
587
|
-
sha256 = "
|
620
|
+
sha256 = "1z4x366icbl9w13pk50vxx5kywlksvhxqxrpv8f5xpjxfl3jl64z";
|
588
621
|
type = "gem";
|
589
622
|
};
|
590
|
-
version = "1.11.
|
623
|
+
version = "1.11.6";
|
591
624
|
};
|
592
625
|
parallel = {
|
593
626
|
groups = ["default" "development"];
|
@@ -847,10 +880,10 @@
|
|
847
880
|
platforms = [];
|
848
881
|
source = {
|
849
882
|
remotes = ["https://rubygems.org"];
|
850
|
-
sha256 = "
|
883
|
+
sha256 = "1xhay8qn3p5f3g6x8i6zh372zk5w2wjrv9dksysxal1r5brkly1w";
|
851
884
|
type = "gem";
|
852
885
|
};
|
853
|
-
version = "1.
|
886
|
+
version = "1.15.0";
|
854
887
|
};
|
855
888
|
rubocop-ast = {
|
856
889
|
dependencies = ["parser"];
|
@@ -858,10 +891,10 @@
|
|
858
891
|
platforms = [];
|
859
892
|
source = {
|
860
893
|
remotes = ["https://rubygems.org"];
|
861
|
-
sha256 = "
|
894
|
+
sha256 = "1hnrfy928mwpa0ippqs4s8xwghwwp5h853naphgqxcd53l33chlv";
|
862
895
|
type = "gem";
|
863
896
|
};
|
864
|
-
version = "1.
|
897
|
+
version = "1.7.0";
|
865
898
|
};
|
866
899
|
ruby-progressbar = {
|
867
900
|
groups = ["default" "development"];
|
@@ -879,10 +912,10 @@
|
|
879
912
|
platforms = [];
|
880
913
|
source = {
|
881
914
|
remotes = ["https://rubygems.org"];
|
882
|
-
sha256 = "
|
915
|
+
sha256 = "18daiaffwniprkfn9xq0njzqr8n37kw2605608njz2gz02m7b1rj";
|
883
916
|
type = "gem";
|
884
917
|
};
|
885
|
-
version = "0.
|
918
|
+
version = "0.41.0";
|
886
919
|
};
|
887
920
|
thor = {
|
888
921
|
groups = ["default"];
|
@@ -1053,6 +1086,26 @@
|
|
1053
1086
|
};
|
1054
1087
|
version = "2.0.10";
|
1055
1088
|
};
|
1089
|
+
time = {
|
1090
|
+
groups = ["default" "development"];
|
1091
|
+
platforms = [];
|
1092
|
+
source = {
|
1093
|
+
remotes = ["https://rubygems.org"];
|
1094
|
+
sha256 = "1ayfwm8b0c6n0z34vwfpmy83lf1gd0mq7jbybzarkqp2ylmdlzvy";
|
1095
|
+
type = "gem";
|
1096
|
+
};
|
1097
|
+
version = "0.1.0";
|
1098
|
+
};
|
1099
|
+
timeout = {
|
1100
|
+
groups = ["default" "development"];
|
1101
|
+
platforms = [];
|
1102
|
+
source = {
|
1103
|
+
remotes = ["https://rubygems.org"];
|
1104
|
+
sha256 = "0lr1pp2hh6np1x9milzs4rim9sfpsb4izhs4dd5q5nnhkcwx8i63";
|
1105
|
+
type = "gem";
|
1106
|
+
};
|
1107
|
+
version = "0.1.1";
|
1108
|
+
};
|
1056
1109
|
unicode-display_width = {
|
1057
1110
|
groups = ["default" "development"];
|
1058
1111
|
platforms = [];
|
data/lib/bushpig.rb
CHANGED
@@ -6,6 +6,7 @@ require 'bushpig/redis_pool'
|
|
6
6
|
require 'bushpig/job'
|
7
7
|
require 'bushpig/client'
|
8
8
|
require 'bushpig/server'
|
9
|
+
require 'bushpig/testing'
|
9
10
|
|
10
11
|
module Bushpig
|
11
12
|
NAME = 'Bushpig'
|
@@ -31,6 +32,14 @@ module Bushpig
|
|
31
32
|
@server = server
|
32
33
|
end
|
33
34
|
|
35
|
+
def self.testing
|
36
|
+
@testing ||= false
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.testing=(testing)
|
40
|
+
@testing = testing
|
41
|
+
end
|
42
|
+
|
34
43
|
def self.configure_server
|
35
44
|
yield self if server?
|
36
45
|
end
|
data/lib/bushpig/client.rb
CHANGED
@@ -19,11 +19,16 @@ module Bushpig
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def submit(queue, job, score: default_score, ttl: default_ttl)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
new = if Bushpig.testing
|
23
|
+
job.handle
|
24
|
+
true
|
25
|
+
else
|
26
|
+
redis_pool.with do |conn|
|
27
|
+
conn.set(Bushpig.job_key(job.job_key), job.job_payload, ex: ttl)
|
28
|
+
conn.zadd(Bushpig.queue_key(queue), score, job.job_key)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
@callback.call(job, new)
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
data/lib/bushpig/job.rb
CHANGED
@@ -30,8 +30,8 @@ module Bushpig
|
|
30
30
|
JSON.generate({ class: self.class.name, id: job_id, args: each.to_a })
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
self.class.job_handler.call(
|
33
|
+
def handle
|
34
|
+
self.class.job_handler.call(self)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -45,6 +45,10 @@ module Bushpig
|
|
45
45
|
@job_handler
|
46
46
|
end
|
47
47
|
|
48
|
+
def self.job_unique_key
|
49
|
+
@unique_key
|
50
|
+
end
|
51
|
+
|
48
52
|
def job_id
|
49
53
|
@job_id ||= SecureRandom.hex(32)
|
50
54
|
end
|
@@ -54,7 +58,7 @@ module Bushpig
|
|
54
58
|
end
|
55
59
|
|
56
60
|
def job_key
|
57
|
-
|
61
|
+
self.class.job_unique_key.inject(Digest::SHA256.new.update(self.class.name)) do |digest, key|
|
58
62
|
digest.update(self[key].to_s)
|
59
63
|
end.hexdigest
|
60
64
|
end
|
@@ -63,8 +67,8 @@ module Bushpig
|
|
63
67
|
JSON.generate({ class: self.class.name, id: job_id, args: each.to_a })
|
64
68
|
end
|
65
69
|
|
66
|
-
def
|
67
|
-
self.class.job_handler.call(
|
70
|
+
def handle
|
71
|
+
self.class.job_handler.call(self)
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|
data/lib/bushpig/server.rb
CHANGED
@@ -37,7 +37,10 @@ module Bushpig
|
|
37
37
|
|
38
38
|
until @done
|
39
39
|
job = fetch(queue)
|
40
|
-
|
40
|
+
if job.nil?
|
41
|
+
ActiveRecord::Base.clear_active_connections!
|
42
|
+
next
|
43
|
+
end
|
41
44
|
|
42
45
|
handle(job)
|
43
46
|
complete(job)
|
@@ -59,6 +62,7 @@ module Bushpig
|
|
59
62
|
elapsed = finished - started
|
60
63
|
puts "Job raised exception: jid-#{job.job_id} #{elapsed} seconds: #{e}"
|
61
64
|
notify_exception(job, e)
|
65
|
+
ActiveRecord::Base.clear_active_connections!
|
62
66
|
end
|
63
67
|
|
64
68
|
def honeybadger
|
data/lib/bushpig/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bushpig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun Sharples
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/bushpig/job.rb
|
163
163
|
- lib/bushpig/redis_pool.rb
|
164
164
|
- lib/bushpig/server.rb
|
165
|
+
- lib/bushpig/testing.rb
|
165
166
|
- lib/bushpig/version.rb
|
166
167
|
- shell.nix
|
167
168
|
homepage: https://github.com/mpowered/bushpig
|
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
191
|
- !ruby/object:Gem::Version
|
191
192
|
version: '0'
|
192
193
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
194
|
+
rubygems_version: 3.2.16
|
194
195
|
signing_key:
|
195
196
|
specification_version: 4
|
196
197
|
summary: Simple job system.
|