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: b6a69a25c27cff265025953ddd3dfaa6f04a4f7e
4
- data.tar.gz: fd175797287181892a619c61dd195d1062919ad4
3
+ metadata.gz: 4d7c52da2120ba9940e89e59ba51357dc635bd6e
4
+ data.tar.gz: 1648ad214dec51e86f96c171d6923f5645a8de61
5
5
  SHA512:
6
- metadata.gz: 1bb62070e8e679707ab12e04590a80a90e61895f02f2aca643248040f57d60257de7e29bc34dc306f89382f2fbf46c5e918a4e0055a52948f4e8a517c0bfe68c
7
- data.tar.gz: 772463884aa0a6ddd64bd5ab83fa311c9881bd4e8156a5fb61253a4ed2c3d0529d5570d842ea99327a92d7adbc42e3f23239d6b05707fe200b8fdccad6a4de87
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), @service_args
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
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '0.2.9'
2
+ VERSION = '0.2.10'
3
3
  end
@@ -59,8 +59,8 @@ describe Services::Base do
59
59
  end
60
60
 
61
61
  context 'when executed asynchronously' do
62
- it 'finds its own worker' do
63
- 3.times { OwnWorkerService.perform_async }
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 + (['reschedule', false]))
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
@@ -3,7 +3,7 @@ require 'sidekiq/api'
3
3
  ExpectedDataNotFoundError = Class.new(StandardError)
4
4
 
5
5
  def wait_for(&block)
6
- 10.tries on: ExpectedDataNotFoundError, delay: 0.1 do
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 0.5 if 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 0.5 if 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 0.5 if 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 0.5 if 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 0.5
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 0.5
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.9
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-25 00:00:00.000000000 Z
11
+ date: 2014-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake