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 +4 -4
- data/.rubocop.yml +67 -0
- data/Gemfile +1 -0
- data/db/migrate/20191022104513_create_midget_jobs.rb +1 -0
- data/lib/generators/midget_jobs/templates/midget_job_initializer.rb +1 -1
- data/lib/midget_jobs/version.rb +1 -1
- data/lib/models/concerns/postgres_notifications_listener.rb +11 -13
- data/midget_job.gemspec +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0381bb924f700b2ab31f3bcee872560499d312666ddac89221f592b9fde9af19'
|
4
|
+
data.tar.gz: f3c51ee3b9950148ec5b4c0803dea0380945c5e34a5672cceb37e52c8ff881b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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.
|
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
|
data/lib/midget_jobs/version.rb
CHANGED
@@ -2,22 +2,20 @@
|
|
2
2
|
|
3
3
|
module PostgresNotificationsListener
|
4
4
|
def listen_notifications
|
5
|
-
Rails.logger.info "#{
|
5
|
+
Rails.logger.info "#{name} listening_job started"
|
6
6
|
Thread.new do
|
7
|
-
Rails.logger.info "#{
|
8
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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", "
|
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.
|
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:
|
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:
|
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:
|
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
|