bushpig 0.1.0 → 0.1.6

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
  SHA256:
3
- metadata.gz: 943fd19120e116d6d2f464584a333f078fe521c9f3be581fd3306f49de59fd9e
4
- data.tar.gz: e41997528a60c54b8ceda3d2f3b16a6925db40c676619936ead2f51e9a17f46b
3
+ metadata.gz: fc9bf6fabf6038b858a576750b32c827ad7095bca278de9bf1ae207258fd0c94
4
+ data.tar.gz: 36be95562838f7868ccc13d76a5e4b77bc75220f18f19693e2fee001d710e21b
5
5
  SHA512:
6
- metadata.gz: 108528f79e94268aae48fef7faf0642bb84f9863059af341e8a9abd2acee1e427715612a733fc832ceea11f078edd90ae389e55750b3de6228fc043a142649de
7
- data.tar.gz: d473123357e0eaf4b2aebdce59bb7170cd2039937a8da846e865bda04ee5cbe96ebab85a5ba0dba9fe02d239477e015b06f29dde94fe8375c7dc56bcb5609d5b
6
+ metadata.gz: cd5f62fdff7ace18ffac4ba7332d29f68a53debeda49f155fe784fe3ff14f2e70ef07cf26623087d134ae7c8e361cd8fe2536afb9f135d05716f850680ae255b
7
+ data.tar.gz: f90b3ba40eb138d0e9a589d9d47f727218761f0a4cc8e022da0fce3395894cd50415f15349cf421a3995a56ecc08582bbe6a9b6b47ea79b1288bbce41e4c5fbe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bushpig (0.1.0)
4
+ bushpig (0.1.6)
5
5
  connection_pool (~> 2.2)
6
6
  json (>= 1.8)
7
7
  redis (~> 3.3)
@@ -17,7 +17,7 @@ GEM
17
17
  connection_pool (2.2.5)
18
18
  e2mmap (0.1.0)
19
19
  jaro_winkler (1.5.4)
20
- json (1.8.6)
20
+ json (2.1.0)
21
21
  kramdown (2.3.1)
22
22
  rexml
23
23
  kramdown-parser-gfm (1.1.0)
data/bin/bushpig CHANGED
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
5
+ # don't buffer output (for logging if running as a systemd service)
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
3
9
  require 'bushpig/cli'
4
10
  Bushpig::CLI.start(ARGV)
data/gemset.nix CHANGED
@@ -9,6 +9,26 @@
9
9
  };
10
10
  version = "2.4.2";
11
11
  };
12
+ backport = {
13
+ groups = ["default" "development"];
14
+ platforms = [];
15
+ source = {
16
+ remotes = ["https://rubygems.org"];
17
+ sha256 = "1xmjljpyx5ly078gi0lmmgkv4y0msxxa3hmv74bzxzp3l8qbn5vc";
18
+ type = "gem";
19
+ };
20
+ version = "1.1.2";
21
+ };
22
+ benchmark = {
23
+ groups = ["default" "development"];
24
+ platforms = [];
25
+ source = {
26
+ remotes = ["https://rubygems.org"];
27
+ sha256 = "1jvrl7400fv7v2jjri1r7ilj3sri36hzipwwgpn5psib4c9c59c6";
28
+ type = "gem";
29
+ };
30
+ version = "0.1.1";
31
+ };
12
32
  bushpig = {
13
33
  dependencies = ["connection_pool" "json" "redis" "thor"];
14
34
  groups = ["default"];
@@ -166,7 +186,7 @@
166
186
  path = ./.;
167
187
  type = "path";
168
188
  };
169
- version = "0.1.0";
189
+ version = "0.1.6";
170
190
  };
171
191
  coderay = {
172
192
  groups = ["default" "development"];
@@ -337,6 +357,26 @@
337
357
  };
338
358
  version = "2.2.5";
339
359
  };
360
+ e2mmap = {
361
+ groups = ["default" "development"];
362
+ platforms = [];
363
+ source = {
364
+ remotes = ["https://rubygems.org"];
365
+ sha256 = "0n8gxjb63dck3vrmsdcqqll7xs7f3wk78mw8w0gdk9wp5nx6pvj5";
366
+ type = "gem";
367
+ };
368
+ version = "0.1.0";
369
+ };
370
+ jaro_winkler = {
371
+ groups = ["default" "development"];
372
+ platforms = [];
373
+ source = {
374
+ remotes = ["https://rubygems.org"];
375
+ sha256 = "1y8l6k34svmdyqxya3iahpwbpvmn3fswhwsvrz0nk1wyb8yfihsh";
376
+ type = "gem";
377
+ };
378
+ version = "1.5.4";
379
+ };
340
380
  json = {
341
381
  groups = ["default"];
342
382
  platforms = [{
@@ -491,10 +531,32 @@
491
531
  }];
492
532
  source = {
493
533
  remotes = ["https://rubygems.org"];
494
- sha256 = "0qmj7fypgb9vag723w1a49qihxrcf5shzars106ynw2zk352gbv5";
534
+ sha256 = "01v6jjpvh3gnq6sgllpfqahlgxzj50ailwhj9b3cd20hi2dx0vxp";
535
+ type = "gem";
536
+ };
537
+ version = "2.1.0";
538
+ };
539
+ kramdown = {
540
+ dependencies = ["rexml"];
541
+ groups = ["default" "development"];
542
+ platforms = [];
543
+ source = {
544
+ remotes = ["https://rubygems.org"];
545
+ sha256 = "0jdbcjv4v7sj888bv3vc6d1dg4ackkh7ywlmn9ln2g9alk7kisar";
546
+ type = "gem";
547
+ };
548
+ version = "2.3.1";
549
+ };
550
+ kramdown-parser-gfm = {
551
+ dependencies = ["kramdown"];
552
+ groups = ["default" "development"];
553
+ platforms = [];
554
+ source = {
555
+ remotes = ["https://rubygems.org"];
556
+ sha256 = "0a8pb3v951f4x7h968rqfsa19c8arz21zw1vaj42jza22rap8fgv";
495
557
  type = "gem";
496
558
  };
497
- version = "1.8.6";
559
+ version = "1.1.0";
498
560
  };
499
561
  method_source = {
500
562
  groups = ["default" "development"];
@@ -506,6 +568,27 @@
506
568
  };
507
569
  version = "1.0.0";
508
570
  };
571
+ mini_portile2 = {
572
+ groups = ["default" "development"];
573
+ platforms = [];
574
+ source = {
575
+ remotes = ["https://rubygems.org"];
576
+ sha256 = "0xg1x4708a4pn2wk8qs2d8kfzzdyv9kjjachg2f1phsx62ap2rx2";
577
+ type = "gem";
578
+ };
579
+ version = "2.5.1";
580
+ };
581
+ nokogiri = {
582
+ dependencies = ["mini_portile2" "racc"];
583
+ groups = ["default" "development"];
584
+ platforms = [];
585
+ source = {
586
+ remotes = ["https://rubygems.org"];
587
+ sha256 = "19d78mdg2lbz9jb4ph6nk783c9jbsdm8rnllwhga6pd53xffp6x0";
588
+ type = "gem";
589
+ };
590
+ version = "1.11.3";
591
+ };
509
592
  parallel = {
510
593
  groups = ["default" "development"];
511
594
  platforms = [];
@@ -538,6 +621,16 @@
538
621
  };
539
622
  version = "0.14.1";
540
623
  };
624
+ racc = {
625
+ groups = ["default" "development"];
626
+ platforms = [];
627
+ source = {
628
+ remotes = ["https://rubygems.org"];
629
+ sha256 = "178k7r0xn689spviqzhvazzvxfq6fyjldxb3ywjbgipbfi4s8j1g";
630
+ type = "gem";
631
+ };
632
+ version = "1.5.2";
633
+ };
541
634
  rainbow = {
542
635
  groups = ["default" "development"];
543
636
  platforms = [];
@@ -727,6 +820,17 @@
727
820
  };
728
821
  version = "2.1.1";
729
822
  };
823
+ reverse_markdown = {
824
+ dependencies = ["nokogiri"];
825
+ groups = ["default" "development"];
826
+ platforms = [];
827
+ source = {
828
+ remotes = ["https://rubygems.org"];
829
+ sha256 = "0w6fv779542vdliq2kmikfhymjv55z8mgzblkfjdy2agl07da9c6";
830
+ type = "gem";
831
+ };
832
+ version = "2.0.0";
833
+ };
730
834
  rexml = {
731
835
  groups = ["default" "development"];
732
836
  platforms = [];
@@ -769,6 +873,17 @@
769
873
  };
770
874
  version = "1.11.0";
771
875
  };
876
+ solargraph = {
877
+ dependencies = ["backport" "benchmark" "e2mmap" "jaro_winkler" "kramdown" "kramdown-parser-gfm" "parser" "reverse_markdown" "rubocop" "thor" "tilt" "yard"];
878
+ groups = ["development"];
879
+ platforms = [];
880
+ source = {
881
+ remotes = ["https://rubygems.org"];
882
+ sha256 = "0xrad7amwf3nmdbif566qprk6xvwydxwz0s7arnzpvr01anc9gcl";
883
+ type = "gem";
884
+ };
885
+ version = "0.40.4";
886
+ };
772
887
  thor = {
773
888
  groups = ["default"];
774
889
  platforms = [{
@@ -928,6 +1043,16 @@
928
1043
  };
929
1044
  version = "1.1.0";
930
1045
  };
1046
+ tilt = {
1047
+ groups = ["default" "development"];
1048
+ platforms = [];
1049
+ source = {
1050
+ remotes = ["https://rubygems.org"];
1051
+ sha256 = "0rn8z8hda4h41a64l0zhkiwz2vxw9b1nb70gl37h1dg2k874yrlv";
1052
+ type = "gem";
1053
+ };
1054
+ version = "2.0.10";
1055
+ };
931
1056
  unicode-display_width = {
932
1057
  groups = ["default" "development"];
933
1058
  platforms = [];
@@ -938,4 +1063,14 @@
938
1063
  };
939
1064
  version = "2.0.0";
940
1065
  };
1066
+ yard = {
1067
+ groups = ["default" "development"];
1068
+ platforms = [];
1069
+ source = {
1070
+ remotes = ["https://rubygems.org"];
1071
+ sha256 = "0qzr5j1a1cafv81ib3i51qyl8jnmwdxlqi3kbiraldzpbjh4ln9h";
1072
+ type = "gem";
1073
+ };
1074
+ version = "0.9.26";
1075
+ };
941
1076
  }
@@ -4,9 +4,10 @@ module Bushpig
4
4
  class Client
5
5
  attr_accessor :default_ttl
6
6
 
7
- def initialize(pool)
7
+ def initialize(pool, &callback)
8
8
  @pool = pool
9
9
  @default_ttl = nil
10
+ @callback = callback
10
11
  end
11
12
 
12
13
  def redis_pool
@@ -18,6 +19,7 @@ module Bushpig
18
19
  end
19
20
 
20
21
  def submit(queue, job, score: default_score, ttl: default_ttl)
22
+ @callback.call(job)
21
23
  redis_pool.with do |conn|
22
24
  conn.set(Bushpig.job_key(job.job_id), job.job_payload, ex: ttl)
23
25
  conn.zadd(Bushpig.set_key(queue), score, job.job_id)
@@ -4,7 +4,7 @@ module Bushpig
4
4
  class Server
5
5
  def initialize(pool, timeout: 2, &handler)
6
6
  @pool = pool
7
- @timeout = timeout.to_f
7
+ @timeout = timeout.to_i
8
8
  @handler = handler
9
9
  @done = false
10
10
  end
@@ -19,10 +19,16 @@ module Bushpig
19
19
  puts 'INT received, shutdown flagged'
20
20
  @done = true
21
21
  end
22
+ Signal.trap('TERM') do
23
+ reset_signals
24
+ puts 'TERM received, shutdown flagged'
25
+ @done = true
26
+ end
22
27
  end
23
28
 
24
29
  def reset_signals
25
30
  Signal.trap('INT', 'DEFAULT')
31
+ Signal.trap('TERM', 'DEFAULT')
26
32
  end
27
33
 
28
34
  def serve(queue)
@@ -49,11 +55,22 @@ module Bushpig
49
55
  elapsed = finished - started
50
56
  puts "Job completed: jid-#{job.job_id} #{elapsed} seconds"
51
57
  rescue StandardError => e
52
- # Job handler raised exception
53
58
  finished = monotonic_time
54
59
  elapsed = finished - started
55
60
  puts "Job raised exception: jid-#{job.job_id} #{elapsed} seconds: #{e}"
56
- # TODO: log exception to honeybadger
61
+ notify_exception(job, e)
62
+ end
63
+
64
+ def honeybadger
65
+ @honeybadger ||= begin
66
+ Honeybadger
67
+ rescue NameError
68
+ nil
69
+ end
70
+ end
71
+
72
+ def notify_exception(job, exception)
73
+ honeybadger&.notify(exception, context: { job_id: job.job_id, job: job.to_s })
57
74
  end
58
75
 
59
76
  def monotonic_time
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bushpig
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.6'
5
5
  end
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.0
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun Sharples