process_handler 3.0.0 → 4.1.0

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
- SHA1:
3
- metadata.gz: 3e495c8a8ec6bf3798941bd11f2792b9a28f1c95
4
- data.tar.gz: 8923ae242c65ba6120b48184588b2534060ff831
2
+ SHA256:
3
+ metadata.gz: e99facc49cfc6587f45cf03e92d33a940b4a0648e5a29dfce3714915d603e5b8
4
+ data.tar.gz: b63e820420d30df0b726d798559a39400afb4c5d09bd6b214438dd335b71e065
5
5
  SHA512:
6
- metadata.gz: 337003df5486731c3b8addbb93e85159e664f20996fda1b22252e111d09831a1b735b3962f242f3f1ec44c88340025ca80356ebf468a1f610be5bc96b2870812
7
- data.tar.gz: 33b8e7e9d3d0f4368a53f11610449b0e5394177cf286495a52d843885e077425d3ff486621ae9a107c8ad2e05e91ec3550b7bea80f79b4de5436c5049379bfc4
6
+ metadata.gz: 876e10d01a71da7f8c979f28702982c1bd4181dace88cf31b3ff30a198005a8d2270ca44f04baa8857ba99d598a54f652dd20e9e188b9174c2b5e11ea65709d3
7
+ data.tar.gz: b38719bc732eec253a91827c861b38f65655b327d556e1b093a257707b55268fdf652c5195f4e4a19ebcc70a280963978611ead196d21b42b85e8d1ce9fe10cd
@@ -0,0 +1,25 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.1']
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+ with:
18
+ submodules: true
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+ - name: Run lint & tests
25
+ run: bundle exec rake
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1
1
+ 2.7.2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ProcessHandler
2
2
 
3
- [![Build Status](https://travis-ci.org/salemove/process_handler.svg?branch=master)](https://travis-ci.org/salemove/process_handler)
3
+ [![Build Status](https://github.com/salemove/process_handler/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/salemove/process_handler/actions/workflows/ci.yml?query=branch%3Amaster)
4
4
  [![Code Climate](https://codeclimate.com/github/salemove/process_handler/badges/gpa.svg)](https://codeclimate.com/github/salemove/process_handler)
5
5
 
6
6
  ProcessHandler helps to spawn and manage services. There are multiple types of processes. Every process knows how to handle `SIGINT` and `SIGTERM` signals.
@@ -42,16 +42,16 @@ module Salemove
42
42
  def spawn(service, blocking: true)
43
43
  @process_monitor.start
44
44
  @schedules.each do |schedule|
45
- spawn_schedule(service, schedule)
45
+ spawn_schedule(service, **schedule)
46
46
  end
47
47
  @scheduler.join if blocking
48
48
  end
49
49
 
50
50
  def spawn_schedule(service, expression:, params:, overlap:)
51
51
  if params.empty?
52
- @scheduler.repeat expression, {overlap: overlap} { service.call }
52
+ @scheduler.repeat(expression, {overlap: overlap}) { service.call }
53
53
  else
54
- @scheduler.repeat expression, {overlap: overlap} { service.call(params) }
54
+ @scheduler.repeat(expression, {overlap: overlap}) { service.call(params) }
55
55
  end
56
56
  end
57
57
 
@@ -1,30 +1,17 @@
1
- require 'airbrake'
2
- require 'growl'
3
- require 'terminal-notifier'
4
-
5
1
  module Salemove
6
2
  module ProcessHandler
7
3
  class NotifierFactory
8
-
9
4
  def self.get_notifier(process_name, conf)
10
- if conf && conf[:type] == 'airbrake'
11
- notifier_name = conf[:notifier_name] || :default
12
- Airbrake.configure(notifier_name) do |airbrake|
13
- airbrake.environment = conf.fetch(:environment)
14
- airbrake.host = conf.fetch(:host)
15
- airbrake.project_id = conf.fetch(:project_id)
16
- airbrake.project_key = conf.fetch(:project_key)
17
- airbrake.ignore_environments = conf[:ignore_environments] if conf[:ignore_environments]
18
- airbrake.whitelist_keys = [
19
- /_HOST$/, /_TCP$/, /_UDP$/, /_PROTO$/, /_ADDR$/, 'PWD',
20
- 'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
21
- 'RACK_ENV', 'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'
22
- ]
23
- end
5
+ return nil unless conf
6
+
7
+ case conf[:type]
8
+ when 'airbrake'
24
9
  AirbrakeNotifier.new
25
- elsif conf && conf[:type] == 'growl'
10
+ when 'sentry'
11
+ SentryNotifier.new
12
+ when 'growl'
26
13
  GrowlNotifier.new(process_name)
27
- elsif conf && conf[:type] == 'terminal-notifier'
14
+ when 'terminal-notifier'
28
15
  TerminalNotifierWrapper.new(process_name)
29
16
  end
30
17
  end
@@ -36,6 +23,12 @@ module Salemove
36
23
  end
37
24
  end
38
25
 
26
+ class SentryNotifier
27
+ def notify_or_ignore(error, params)
28
+ Raven.capture_exception(error, extra: params)
29
+ end
30
+ end
31
+
39
32
  class GrowlNotifier
40
33
  def initialize(process_name)
41
34
  @process_name = process_name
@@ -1,5 +1,6 @@
1
1
  require 'benchmark'
2
2
  require 'securerandom'
3
+ require 'timeout'
3
4
  require_relative 'process_monitor'
4
5
  require_relative 'notifier_factory'
5
6
 
@@ -176,7 +177,7 @@ module Salemove
176
177
  end
177
178
 
178
179
  def delegate_to_service(input)
179
- result = @benchmarker.call(input) { @service.call(input) }
180
+ result = @benchmarker.call(input) { @service.call(**input) }
180
181
 
181
182
  unless result.respond_to?(:fulfilled?)
182
183
  log_processed_request(input, result)
@@ -1,5 +1,5 @@
1
1
  module Salemove
2
2
  module ProcessHandler
3
- VERSION = '3.0.0'
3
+ VERSION = '4.1.0'
4
4
  end
5
5
  end
@@ -17,10 +17,4 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency 'airbrake', '~> 7.4'
22
- spec.add_dependency 'timers', '~> 4.1.2'
23
- spec.add_dependency 'sucker_punch', '~> 1.1' # for async airbrake notifications
24
- spec.add_dependency 'growl'
25
- spec.add_dependency 'terminal-notifier'
26
20
  end
@@ -1,3 +1,4 @@
1
+ require 'logger'
1
2
  require 'salemove/process_handler'
2
3
  require 'salemove/process_handler/composite_process'
3
4
  require 'salemove/process_handler/cron_process'
@@ -42,7 +42,7 @@ describe ProcessHandler::CronProcess do
42
42
  end
43
43
 
44
44
  describe 'scheduler' do
45
- let(:process) { ProcessHandler::CronProcess.new(scheduler_options: {frequency: 0.1}) }
45
+ let(:process) { ProcessHandler::CronProcess.new(**{scheduler_options: {frequency: 0.1}}) }
46
46
  let(:messages) { [] }
47
47
  let(:queue) { Queue.new }
48
48
 
@@ -60,7 +60,7 @@ describe ProcessHandler::CronProcess do
60
60
  end
61
61
 
62
62
  describe 'exception handler' do
63
- let(:process) { ProcessHandler::CronProcess.new(params) }
63
+ let(:process) { ProcessHandler::CronProcess.new(**params) }
64
64
  let(:params) {{ notifier_factory: notifier_factory,
65
65
  scheduler_options: {frequency: 0.2} }}
66
66
  let(:notifier_factory) { double('NotifierFactory') }
metadata CHANGED
@@ -1,85 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SaleMove TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: airbrake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '7.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '7.4'
27
- - !ruby/object:Gem::Dependency
28
- name: timers
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 4.1.2
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 4.1.2
41
- - !ruby/object:Gem::Dependency
42
- name: sucker_punch
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.1'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.1'
55
- - !ruby/object:Gem::Dependency
56
- name: growl
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: terminal-notifier
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
+ dependencies: []
83
13
  description: This gem helps to monitor and manage processes
84
14
  email:
85
15
  - techmovers@salemove.com
@@ -87,10 +17,10 @@ executables: []
87
17
  extensions: []
88
18
  extra_rdoc_files: []
89
19
  files:
20
+ - ".github/workflows/ci.yml"
90
21
  - ".gitignore"
91
22
  - ".ruby-gemset"
92
23
  - ".ruby-version"
93
- - ".travis.yml"
94
24
  - Gemfile
95
25
  - LICENSE
96
26
  - README.md
@@ -107,7 +37,6 @@ files:
107
37
  - process_handler.gemspec
108
38
  - spec/fixtures/composite_service.rb
109
39
  - spec/fixtures/cron_service.rb
110
- - spec/process_handler/airbrake_spec.rb
111
40
  - spec/process_handler/composite_process_spec.rb
112
41
  - spec/process_handler/cron_process_spec.rb
113
42
  - spec/process_handler/pivot_process_spec.rb
@@ -131,15 +60,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
60
  - !ruby/object:Gem::Version
132
61
  version: '0'
133
62
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.2.5
63
+ rubygems_version: 3.1.4
136
64
  signing_key:
137
65
  specification_version: 4
138
66
  summary: ''
139
67
  test_files:
140
68
  - spec/fixtures/composite_service.rb
141
69
  - spec/fixtures/cron_service.rb
142
- - spec/process_handler/airbrake_spec.rb
143
70
  - spec/process_handler/composite_process_spec.rb
144
71
  - spec/process_handler/cron_process_spec.rb
145
72
  - spec/process_handler/pivot_process_spec.rb
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.0
4
- before_script:
5
- - bundle
6
- script: bundle exec rspec
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
- require 'salemove/process_handler/notifier_factory'
3
- require 'securerandom'
4
-
5
- describe 'Airbrake configuration' do
6
- let(:environment) { 'SOME_ENVIRONMENT' }
7
- let(:config) { airbrake_config.merge(type: 'airbrake') }
8
- let(:airbrake_config) { base_params }
9
- let(:base_params) do
10
- {
11
- environment: environment,
12
- host: 'localhost',
13
- project_id: '123456',
14
- project_key: 'abc123',
15
- ignore_environments: ['dev'],
16
- # Airbrake module raises an error when same notifier configured multiple times
17
- # Provide a random notifier name for each test case
18
- notifier_name: SecureRandom.hex
19
- }
20
- end
21
- let(:airbrake) do
22
- ProcessHandler::NotifierFactory.get_notifier('Process name', config)
23
- end
24
-
25
- context 'when all params set' do
26
- it 'does not raise an error' do
27
- expect { airbrake }.not_to raise_error
28
- end
29
- end
30
-
31
- context 'when project_id is not a number' do
32
- let(:airbrake_config) { base_params.merge(project_id: 'abc') }
33
-
34
- it 'raises error' do
35
- expect { airbrake }.to raise_error
36
- end
37
- end
38
-
39
- context 'when ignore_environments missing' do
40
- before { base_params.delete(:ignore_environments) }
41
-
42
- it 'does not raise an error' do
43
- expect { airbrake }.not_to raise_error
44
- end
45
- end
46
-
47
- shared_examples_for 'raises error if config param missing' do |key|
48
- context "when #{key} missing" do
49
- before { base_params.delete(key) }
50
-
51
- it 'raises error' do
52
- expect { airbrake }.to raise_error
53
- end
54
- end
55
- end
56
-
57
- it_behaves_like 'raises error if config param missing', :environment
58
- it_behaves_like 'raises error if config param missing', :host
59
- it_behaves_like 'raises error if config param missing', :project_id
60
- it_behaves_like 'raises error if config param missing', :project_key
61
- end