assistor 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +1 -4
- data/lib/assistor/abstract_job.rb +0 -4
- data/lib/assistor/assistant.rb +2 -2
- data/lib/assistor/assistant_group.rb +1 -1
- data/lib/assistor/configuration.rb +8 -0
- data/lib/assistor/daemon.rb +4 -1
- data/lib/assistor/version.rb +1 -1
- data/lib/assistor.rb +2 -0
- metadata +18 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1fa2ddaa11e30636eb624ee437c724f2a1602fdf4951cf386d1039ccc7b4d664
|
4
|
+
data.tar.gz: 52f0e901cb875e920d43e677592f11dd4f20b045f7dd8752b95f5dd20c9a23e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c5f78349106336a9716bb07ab1835309ae587b9aef14da0a9bb9c84aabb4183e480a0f667e651d8fa2f3759178573084ae4bad7d1223cc4ea67086cb5b2a77b
|
7
|
+
data.tar.gz: e0d5c02282a5929a2e5e0f89bb09ba1c77b084b6c168dc4b6a0dda723ac0ccee2c8c38d1ea2f44f5b03bd81fe9978bf3be924d645b825962fbec6634f89778e7
|
data/README.md
CHANGED
@@ -48,10 +48,6 @@ class ExampleJob < Assistor::AbstractJob
|
|
48
48
|
def run
|
49
49
|
sleep @i
|
50
50
|
end
|
51
|
-
|
52
|
-
def fail(exception)
|
53
|
-
ExceptionHandler.handle exception
|
54
|
-
end
|
55
51
|
end
|
56
52
|
|
57
53
|
class ExampleQueue < Assistor::AbstractQueue
|
@@ -77,6 +73,7 @@ configuration = Assistor::Configuration.new
|
|
77
73
|
configuration.id = 'example'
|
78
74
|
configuration.size = 3
|
79
75
|
configuration.delay = 0.2
|
76
|
+
configuration.exception_handler = Proc.new { |exception| ExceptionHandler.handle(exception) }_
|
80
77
|
configuration.log_file = File.join(File.expand_path('..', __FILE__), 'example.log')
|
81
78
|
configuration.pid_file = File.join(File.expand_path('..', __FILE__), 'example.pid')
|
82
79
|
|
data/lib/assistor/assistant.rb
CHANGED
@@ -48,7 +48,7 @@ module Assistor
|
|
48
48
|
with_pid_file { @job.run }
|
49
49
|
rescue => e
|
50
50
|
log_file.error e
|
51
|
-
@
|
51
|
+
@configuration.exception_handler.call(e)
|
52
52
|
end
|
53
53
|
|
54
54
|
def stop
|
@@ -106,7 +106,7 @@ module Assistor
|
|
106
106
|
def with_pid_file
|
107
107
|
pid_file.create Process.pid
|
108
108
|
yield
|
109
|
-
pid_file.delete
|
109
|
+
pid_file.delete
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -10,5 +10,13 @@ module Assistor
|
|
10
10
|
def pid_file=(file)
|
11
11
|
@pid_file = PidFile.new file
|
12
12
|
end
|
13
|
+
|
14
|
+
def exception_handler(exception_handler)
|
15
|
+
@exception_handler = exception_handler
|
16
|
+
end
|
17
|
+
|
18
|
+
def exception_handler
|
19
|
+
@exception_handler || Proc.new {}
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
data/lib/assistor/daemon.rb
CHANGED
@@ -17,9 +17,9 @@ module Assistor
|
|
17
17
|
loop do
|
18
18
|
sleep(delay) unless assist(queue)
|
19
19
|
end
|
20
|
-
stop
|
21
20
|
rescue => e
|
22
21
|
log_file.error e
|
22
|
+
@configuration.exception_handler.call(e)
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
@@ -39,6 +39,7 @@ module Assistor
|
|
39
39
|
exit!(0)
|
40
40
|
rescue => e
|
41
41
|
log_file.error e
|
42
|
+
@configuration.exception_handler.call(e)
|
42
43
|
end
|
43
44
|
|
44
45
|
def stop!
|
@@ -48,6 +49,7 @@ module Assistor
|
|
48
49
|
exit!(1)
|
49
50
|
rescue => e
|
50
51
|
log_file.error e
|
52
|
+
@configuration.exception_handler.call(e)
|
51
53
|
end
|
52
54
|
|
53
55
|
def assist(queue)
|
@@ -61,6 +63,7 @@ module Assistor
|
|
61
63
|
assistant_group.add(assistant)
|
62
64
|
rescue => e
|
63
65
|
log_file.error e
|
66
|
+
@configuration.exception_handler.call(e)
|
64
67
|
end
|
65
68
|
|
66
69
|
def daemonize
|
data/lib/assistor/version.rb
CHANGED
data/lib/assistor.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assistor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Kowalewski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
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: '0'
|
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: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.44.1
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.44.1
|
54
|
+
version: '0'
|
69
55
|
description: Simple background processing framework for Ruby
|
70
56
|
email:
|
71
57
|
- me@tkowalewski.pl
|
@@ -91,7 +77,7 @@ homepage: https://github.com/tkowalewski/assistor
|
|
91
77
|
licenses:
|
92
78
|
- MIT
|
93
79
|
metadata: {}
|
94
|
-
post_install_message:
|
80
|
+
post_install_message:
|
95
81
|
rdoc_options: []
|
96
82
|
require_paths:
|
97
83
|
- lib
|
@@ -106,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
92
|
- !ruby/object:Gem::Version
|
107
93
|
version: '0'
|
108
94
|
requirements: []
|
109
|
-
|
110
|
-
|
111
|
-
signing_key:
|
95
|
+
rubygems_version: 3.1.2
|
96
|
+
signing_key:
|
112
97
|
specification_version: 4
|
113
98
|
summary: Simple background processing framework for Ruby
|
114
99
|
test_files: []
|