services 0.2.9 → 0.2.10
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d7c52da2120ba9940e89e59ba51357dc635bd6e
|
4
|
+
data.tar.gz: 1648ad214dec51e86f96c171d6923f5645a8de61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd8efa7089b8d5b9b0f2d825ec613079b1dd96729fc0630deed1e6a158f1d4a60aeea39112f6a596deac973ea87d280a2173e1810b1b1d512c88c84714e79f6
|
7
|
+
data.tar.gz: d3e2d308aff905357e9bf597f049b569a562a57eb00636a11a2e2baaa626190babd580936ef99b53152406599ab68026f97268f5242d9edb631db6fad9253752
|
@@ -37,7 +37,7 @@ module Services
|
|
37
37
|
raise_non_unique_error
|
38
38
|
else
|
39
39
|
error_count += 1
|
40
|
-
self.class.perform_in retry_delay(error_count),
|
40
|
+
self.class.perform_in retry_delay(error_count), *@service_args
|
41
41
|
Services.configuration.redis.setex error_count_key, retry_delay(error_count) + ONE_HOUR, error_count
|
42
42
|
false
|
43
43
|
end
|
data/lib/services/version.rb
CHANGED
data/spec/services/base_spec.rb
CHANGED
@@ -59,8 +59,8 @@ describe Services::Base do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
context 'when executed asynchronously' do
|
62
|
-
|
63
|
-
|
62
|
+
fit 'finds its own worker' do
|
63
|
+
2.times { OwnWorkerService.perform_async }
|
64
64
|
jid = OwnWorkerService.perform_async
|
65
65
|
own_worker_data = wait_for { Services.configuration.redis.get(jid) }
|
66
66
|
own_worker_json = JSON.parse(own_worker_data)
|
@@ -39,7 +39,7 @@ shared_examples 'checking the uniqueness properly' do
|
|
39
39
|
if defined?(fail_args)
|
40
40
|
3.times do
|
41
41
|
fail_args.each do |fail_arg_group|
|
42
|
-
expect(service).to receive(:perform_in).with(an_instance_of(Fixnum), fail_arg_group
|
42
|
+
expect(service).to receive(:perform_in).with(an_instance_of(Fixnum), *fail_arg_group, 'reschedule', false)
|
43
43
|
service.call(*fail_arg_group, 'reschedule', false)
|
44
44
|
end
|
45
45
|
end
|
data/spec/support/helpers.rb
CHANGED
@@ -3,7 +3,7 @@ require 'sidekiq/api'
|
|
3
3
|
ExpectedDataNotFoundError = Class.new(StandardError)
|
4
4
|
|
5
5
|
def wait_for(&block)
|
6
|
-
|
6
|
+
20.tries on: ExpectedDataNotFoundError, delay: 0.2 do
|
7
7
|
block.call or raise ExpectedDataNotFoundError
|
8
8
|
end
|
9
9
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# How long should the services sleep to ensure
|
2
|
+
# that other services can be run in the meantime?
|
3
|
+
SERVICE_SLEEP = 1 # seconds
|
4
|
+
|
1
5
|
class Model
|
2
6
|
attr_reader :id
|
3
7
|
|
@@ -67,14 +71,14 @@ end
|
|
67
71
|
class UniqueService < Services::Base
|
68
72
|
def call(on_error, sleep)
|
69
73
|
check_uniqueness! on_error: on_error
|
70
|
-
sleep
|
74
|
+
sleep SERVICE_SLEEP if sleep
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
74
78
|
class UniqueWithCustomArgsService < Services::Base
|
75
79
|
def call(uniqueness_arg1, uniqueness_arg2, ignore_arg, on_error, sleep)
|
76
80
|
check_uniqueness! uniqueness_arg1, uniqueness_arg2, on_error: on_error
|
77
|
-
sleep
|
81
|
+
sleep SERVICE_SLEEP if sleep
|
78
82
|
end
|
79
83
|
end
|
80
84
|
|
@@ -83,13 +87,13 @@ class UniqueMultipleService < Services::Base
|
|
83
87
|
args.each do |arg|
|
84
88
|
check_uniqueness! arg, on_error: on_error
|
85
89
|
end
|
86
|
-
sleep
|
90
|
+
sleep SERVICE_SLEEP if sleep
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
90
94
|
class NonUniqueService < Services::Base
|
91
95
|
def call(on_error, sleep)
|
92
|
-
sleep
|
96
|
+
sleep SERVICE_SLEEP if sleep
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
@@ -100,7 +104,7 @@ class OwnWorkerService < Services::Base
|
|
100
104
|
else
|
101
105
|
Services.configuration.redis.set self.jid, own_worker.to_json
|
102
106
|
end
|
103
|
-
sleep
|
107
|
+
sleep SERVICE_SLEEP
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
@@ -111,7 +115,7 @@ class SiblingWorkersService < Services::Base
|
|
111
115
|
else
|
112
116
|
Services.configuration.redis.set self.jid, sibling_workers.to_json
|
113
117
|
end
|
114
|
-
sleep
|
118
|
+
sleep SERVICE_SLEEP
|
115
119
|
end
|
116
120
|
end
|
117
121
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|