process_handler 0.3.0 → 1.0.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
2
  SHA1:
3
- metadata.gz: 96dfb240ae4f597188a5ff12c95fa1f9d8478365
4
- data.tar.gz: ebc125a0ca392c0ca7f7754650a5ae80290dfe2b
3
+ metadata.gz: a4a0b0712332a3351be93705ac3d10cb25aac695
4
+ data.tar.gz: 04ef8921eeafe7704d6239252f81f6cf992cc723
5
5
  SHA512:
6
- metadata.gz: 9c6aac593c894445137330a8d812dff1c03b81ccdae5254c1203659d30bf8aa2236ed844236b7859c1eb870517fe04f4f6d696a8c38ce706381ca47af69bc894
7
- data.tar.gz: 9cdf6d9278e73b532dc853b52eb69f54ae1efbbf04f257fdc9e89a85503887b521cac5a2b4ce56ed6b32ffb5c2a8d6695aad5f5ed59e860cd2c92fa8d7684a64
6
+ metadata.gz: 5eedc6fa3ecc33d660884c3db2260b06e78ea20c61bf3305f20cb412c7c426d55e9834ddf8ba822076e77715cfb93ed9357e4d390dd79ab2ae464c6eee0832de
7
+ data.tar.gz: efbe06f03d975f036c7a80f8beb3af369cd1f0a273b5c3a00e3cc8da208cba7995933b69d56fab224a122a13f84dd137892dded74f2205c24da57c1ccfd8a09c
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016-2017 SaleMove Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -25,12 +25,11 @@ module Salemove
25
25
 
26
26
  attr_reader :process_monitor
27
27
 
28
- def initialize(env: 'development',
29
- notifier: nil,
28
+ def initialize(notifier: nil,
30
29
  notifier_factory: NotifierFactory,
31
30
  scheduler_options: {})
32
31
  @schedules = []
33
- @exception_notifier = notifier_factory.get_notifier(env, 'Cron Process', notifier)
32
+ @exception_notifier = notifier_factory.get_notifier('Cron Process', notifier)
34
33
  @scheduler = CronScheduler.new @exception_notifier, scheduler_options
35
34
  @process_monitor = CronProcessMonitor.new(self)
36
35
  end
@@ -6,18 +6,18 @@ module Salemove
6
6
  module ProcessHandler
7
7
  class NotifierFactory
8
8
 
9
- def self.get_notifier(env, process_name, conf)
9
+ def self.get_notifier(process_name, conf)
10
10
  if conf && conf[:type] == 'airbrake'
11
11
  Airbrake.configure do |airbrake|
12
12
  airbrake.async = true
13
- airbrake.environment_name = env
13
+ airbrake.environment_name = conf.fetch(:environment_name)
14
14
  airbrake.secure = true
15
15
  airbrake.host = conf.fetch(:host)
16
16
  airbrake.api_key = conf.fetch(:api_key)
17
17
  [/_HOST$/, /_TCP$/, /_UDP$/, /_PROTO$/, /_ADDR$/, 'PWD',
18
- 'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
19
- 'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'].each {
20
- | param_whitelist_filter| airbrake.params_whitelist_filters << param_whitelist_filter
18
+ 'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
19
+ 'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'].each {
20
+ | param_whitelist_filter| airbrake.params_whitelist_filters << param_whitelist_filter
21
21
  }
22
22
  end
23
23
  Airbrake
@@ -21,7 +21,6 @@ module Salemove
21
21
  end
22
22
 
23
23
  def initialize(messenger,
24
- env: 'development',
25
24
  notifier: nil,
26
25
  notifier_factory: NotifierFactory,
27
26
  process_monitor: ProcessMonitor.new,
@@ -29,7 +28,7 @@ module Salemove
29
28
  exit_enforcer: nil)
30
29
  @messenger = messenger
31
30
  @process_monitor = process_monitor
32
- @exception_notifier = notifier_factory.get_notifier(env, process_name, notifier)
31
+ @exception_notifier = notifier_factory.get_notifier(process_name, notifier)
33
32
  # Needed for forcing exit from jruby with exit(0)
34
33
  @exit_enforcer = exit_enforcer || Proc.new {}
35
34
  end
@@ -1,5 +1,5 @@
1
1
  module Salemove
2
2
  module ProcessHandler
3
- VERSION = '0.3.0'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -6,14 +6,19 @@ require 'salemove/process_handler/notifier_factory'
6
6
  describe 'Airbrake configuration' do
7
7
 
8
8
  let (:notice) { Airbrake::Notice.new(notice_args.merge(custom_notice_args)) }
9
- let (:notifier_factory_conf) { {:type => 'airbrake',:host => 'localhost',:api_key => 'abc123'} }
10
- let (:airbrake) { ProcessHandler::NotifierFactory.get_notifier('env', 'Process name', notifier_factory_conf) }
9
+ let (:environment_name) { 'SOME_ENVIRONMENT' }
10
+ let (:notifier_factory_conf) { {:type => 'airbrake',
11
+ :host => 'localhost',
12
+ :api_key => 'abc123',
13
+ :environment_name => environment_name} }
14
+ let (:airbrake) { ProcessHandler::NotifierFactory.get_notifier('Process name', notifier_factory_conf) }
11
15
  # Notice needs Airbrake configuration merged with :exception for creating the exception notification
12
16
  let (:notice_args) { {:exception => Exception.new}.merge(airbrake.configuration) }
17
+ let (:custom_notice_args) { {} }
13
18
  let (:filtered) { '[FILTERED]' }
14
19
 
15
20
  # Uses Airbrake configuration's 'params_whitelist_filters' param for filtering
16
- context 'whitelist filter' do
21
+ describe 'whitelist filtering' do
17
22
 
18
23
  let (:custom_notice_args) {
19
24
  {
@@ -52,4 +57,7 @@ describe 'Airbrake configuration' do
52
57
 
53
58
  end
54
59
 
60
+ it 'configures environment_name' do
61
+ expect(notice[:environment_name]).to eq environment_name
62
+ end
55
63
  end
@@ -61,7 +61,7 @@ describe ProcessHandler::CronProcess do
61
61
 
62
62
  describe 'exception handler' do
63
63
  let(:process) { ProcessHandler::CronProcess.new(params) }
64
- let(:params) {{ env: 'test', notifier_factory: notifier_factory,
64
+ let(:params) {{ notifier_factory: notifier_factory,
65
65
  scheduler_options: {frequency: 0.2} }}
66
66
  let(:notifier_factory) { double('NotifierFactory') }
67
67
  let(:exception_notifier) { double('Airbrake') }
@@ -8,10 +8,10 @@ describe ProcessHandler::PivotProcess do
8
8
  let(:handler) { double('Handler') }
9
9
  let(:thread) { double('Thread') }
10
10
  let(:process) { ProcessHandler::PivotProcess.new(messenger, process_params) }
11
- let(:process_params) {{ process_monitor: monitor , notifier_factory: notifier_factory, env: 'test' }}
11
+ let(:process_params) {{ process_monitor: monitor , notifier_factory: notifier_factory}}
12
12
  let(:notifier_factory) { double('NotifierFactory') }
13
13
  let(:responder) { double(shutdown: true) }
14
- let(:logger) { Logasm.new([]) }
14
+ let(:logger) { Logasm.build('test-app', []) }
15
15
 
16
16
  def expect_monitor_to_behave
17
17
  expect(monitor).to receive(:start)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indrek Juhkam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-15 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: airbrake
@@ -78,6 +78,7 @@ files:
78
78
  - ".ruby-version"
79
79
  - ".travis.yml"
80
80
  - Gemfile
81
+ - LICENSE
81
82
  - README.md
82
83
  - Rakefile
83
84
  - config.reek
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  version: '0'
118
119
  requirements: []
119
120
  rubyforge_project:
120
- rubygems_version: 2.4.8
121
+ rubygems_version: 2.6.8
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: ''