midget_jobs 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46487fe4dd4186446042dabb5302257cb50c53e06364cc31d829407fcf15dabe
4
- data.tar.gz: e28b11bf2e2aef9f47a8cdcedc5f734643ffab3288e7ca8111179f13b6a971cd
3
+ metadata.gz: '0381bb924f700b2ab31f3bcee872560499d312666ddac89221f592b9fde9af19'
4
+ data.tar.gz: f3c51ee3b9950148ec5b4c0803dea0380945c5e34a5672cceb37e52c8ff881b5
5
5
  SHA512:
6
- metadata.gz: e5874e3d1766aa00e307a679d5692b22cdcdb54eda928be07068c24838cbbda7b2da026c0494ca3cc2ec22deb6f08e1851fe2fc0ef979f8cd571187cba42fc80
7
- data.tar.gz: 0bdf9bc6dbe7f94fd8a44490901113e9df106b4d978a9db16ebbb6a983a5cbc76060ec0091dda1e65a54a2e545649fd324e177d01c005fe9cfc10b208b49689b
6
+ metadata.gz: c37ac71de44ca971da13aae9b8a2a17e2b7777904ca0a8fa777c495a2c5d3a1d7276b3b447937e01b734bb45b9caaf34fbd12961731cfa6f36f9e01849768781
7
+ data.tar.gz: 5f3f5b3e68a5b3876cf8df4f3b652c8cf64d60361eaa55ec57fd6a9d2e3b755051b0810019e83cdb7fe31bc76d90937c7662fe17fed2d04c69d5c77a32276031
data/.rubocop.yml ADDED
@@ -0,0 +1,67 @@
1
+ # all the cops that are enabled in the default
2
+ # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
3
+ # https://github.com/bbatsov/rubocop/blob/master/config/default.yml
4
+
5
+ require: rubocop-performance
6
+ require: rubocop-rails
7
+
8
+ AllCops:
9
+ TargetRubyVersion: 2.6
10
+ Include:
11
+ - '**/Rakefile'
12
+ - '**/config.ru'
13
+ Exclude:
14
+ - 'db/**/*'
15
+ - 'config/**/*'
16
+ - 'script/**/*'
17
+ - !ruby/regexp /old_and_unused\.rb$/
18
+
19
+ Layout/LineLength:
20
+ Max: 160
21
+
22
+ Metrics/MethodLength:
23
+ CountComments: false # count full line comments?
24
+ Max: 12
25
+
26
+ Metrics/AbcSize:
27
+ Max: 20
28
+
29
+ Style/AndOr:
30
+ Enabled: false
31
+
32
+ Documentation:
33
+ Enabled: false
34
+
35
+ Style/ClassAndModuleChildren:
36
+ # Checks the style of children definitions at classes and modules.
37
+ #
38
+ # Basically there are two different styles:
39
+ #
40
+ # `nested` - have each child on a separate line
41
+ # class Foo
42
+ # class Bar
43
+ # end
44
+ # end
45
+ #
46
+ # `compact` - combine definitions as much as possible
47
+ # class Foo::Bar
48
+ # end
49
+ #
50
+ # The compact style is only forced, for classes / modules with one child.
51
+ EnforcedStyle: nested
52
+ SupportedStyles:
53
+ - nested
54
+ - compact
55
+ Enabled: false
56
+
57
+ CaseIndentation:
58
+ # Valid values are: case, end
59
+ EnforcedStyle: case
60
+ IndentOneStep: true
61
+
62
+ # Prefer `has_?` style for Hash methods
63
+ Style/PreferredHashMethods:
64
+ EnforcedStyle: verbose
65
+
66
+ Rails:
67
+ Enabled: true
data/Gemfile CHANGED
@@ -12,4 +12,5 @@ group :test do
12
12
  gem 'activerecord'
13
13
  gem 'pg'
14
14
  gem 'activesupport'
15
+ gem 'simplecov', require: false
15
16
  end
@@ -10,5 +10,6 @@ class CreateMidgetJobs < ActiveRecord::Migration[6.0]
10
10
  t.timestamps
11
11
  end
12
12
  add_index :midget_jobs, :queue
13
+ add_index :midget_jobs, :runner
13
14
  end
14
15
  end
@@ -1,6 +1,6 @@
1
1
  Rails.application.config.active_job.queue_adapter = :midget_job
2
2
  Rails.application.config.x.midget_jobs.at_once = 4
3
- Rails.application.config.x.midget_jobs.runner = Rails.application.class.parent_name
3
+ Rails.application.config.x.midget_jobs.runner = Rails.application.class.module_parent_name
4
4
 
5
5
  if Rails.const_defined?('Server') || $0.include?('puma')
6
6
  Rails.application.config.after_initialize do
@@ -1,3 +1,3 @@
1
1
  module MidgetJobs
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -2,22 +2,20 @@
2
2
 
3
3
  module PostgresNotificationsListener
4
4
  def listen_notifications
5
- Rails.logger.info "#{self.name} listening_job started"
5
+ Rails.logger.info "#{name} listening_job started"
6
6
  Thread.new do
7
- Rails.logger.info "#{self.name} listening_job running on #{self.name.pluralize.underscore}_notices"
8
- self.connection.execute "LISTEN #{self.name.pluralize.underscore}_notices"
7
+ Rails.logger.info "#{name} listening_job running on #{name.pluralize.underscore}_notices"
8
+ connection.execute "LISTEN #{name.pluralize.underscore}_notices"
9
9
  loop do
10
- begin
11
- Rails.logger.info "#{self.name} listening_job wait_for_notify"
12
- self.connection.raw_connection.wait_for_notify do |event, pid, payload|
13
- data = JSON.parse payload, symbolize_names: true
14
- Rails.logger.info "postgres #{event.inspect}, pid: #{pid.inspect}, data: #{data.inspect}"
15
- process_notification(data)
16
- end
17
- rescue StandardError => error
18
- Rails.logger.error "-------------Ex #{self.name} listening_job wait_for_notify #{error}----------------"
19
- retry
10
+ Rails.logger.info "#{name} listening_job wait_for_notify"
11
+ connection.raw_connection.wait_for_notify do |event, pid, payload|
12
+ data = JSON.parse payload, symbolize_names: true
13
+ Rails.logger.info "postgres #{event.inspect}, pid: #{pid.inspect}, data: #{data.inspect}"
14
+ process_notification(data)
20
15
  end
16
+ rescue StandardError => e
17
+ Rails.logger.error "-----------Ex #{name} listening_job wait_for_notify #{e}-retrying!------------"
18
+ retry
21
19
  end
22
20
  end.abort_on_exception = true
23
21
  end
data/midget_job.gemspec CHANGED
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  spec.add_development_dependency "bundler", "~> 2.0"
32
- spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rake", ">= 12.3.3"
33
33
  spec.add_development_dependency "minitest", "~> 5.0"
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midget_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - josefchmel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-19 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".rubocop.yml"
63
64
  - ".travis.yml"
64
65
  - CODE_OF_CONDUCT.md
65
66
  - Gemfile