services 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/services/modules/uniqueness_checker.rb +28 -13
- data/lib/services/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 633721b985b22ab22c0f05134d9d596cb1c3e8e7
|
4
|
+
data.tar.gz: 296c454079604408722442164aec3999a842ca54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd8b3a5e499a3c6ba052d6a6dd6fb84dc25be6677571aca9d8aeb6192ebb54334f3d4604cf51da3181a60c93d0b70550b5ef396dbfe9b76ac66ffdfbbf9499ee
|
7
|
+
data.tar.gz: 1766463f9ab6d43dcc242dccaa2c0e6d585945f6613e59b17627bfceb99868c112ce2594d83435aff94982e9faa6059e5e07f1efa69b02bb9387c56fb1bf7baf
|
@@ -30,13 +30,11 @@ module Services
|
|
30
30
|
when :fail
|
31
31
|
raise_non_unique_error
|
32
32
|
when :reschedule
|
33
|
-
|
34
|
-
if @error_count >= MAX_RETRIES
|
33
|
+
if error_count >= MAX_RETRIES
|
35
34
|
raise_non_unique_error
|
36
35
|
else
|
37
|
-
|
36
|
+
increase_error_count
|
38
37
|
reschedule
|
39
|
-
Services.configuration.redis.setex error_count_key, retry_delay + ONE_HOUR, @error_count
|
40
38
|
end
|
41
39
|
end
|
42
40
|
false
|
@@ -64,21 +62,38 @@ module Services
|
|
64
62
|
raise self.class::NotUniqueError, message
|
65
63
|
end
|
66
64
|
|
65
|
+
def convert_for_rescheduling(arg)
|
66
|
+
case arg
|
67
|
+
when Array
|
68
|
+
arg.map do |array_arg|
|
69
|
+
convert_for_rescheduling array_arg
|
70
|
+
end
|
71
|
+
when Fixnum, String, TrueClass, FalseClass, NilClass
|
72
|
+
arg
|
73
|
+
when service_class
|
74
|
+
arg.id
|
75
|
+
else
|
76
|
+
raise "Don't know how to convert arg #{arg.inspect} for rescheduling."
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
67
80
|
def reschedule
|
68
81
|
# Convert service args to fixnums first
|
69
82
|
reschedule_args = @service_args.map do |arg|
|
70
|
-
|
71
|
-
when Fixnum, String, TrueClass, FalseClass, NilClass
|
72
|
-
arg
|
73
|
-
when service_class && arg.respond_to?(:id)
|
74
|
-
arg.id
|
75
|
-
else
|
76
|
-
raise "Don't know how to convert arg #{arg.inspect} for rescheduling."
|
77
|
-
end
|
83
|
+
convert_for_rescheduling arg
|
78
84
|
end
|
79
85
|
self.class.perform_in retry_delay, *reschedule_args
|
80
86
|
end
|
81
87
|
|
88
|
+
def error_count
|
89
|
+
(Services.configuration.redis.get(error_count_key) || 0).to_i
|
90
|
+
end
|
91
|
+
|
92
|
+
def increase_error_count
|
93
|
+
Services.configuration.redis.incr error_count_key
|
94
|
+
Services.configuration.redis.setex error_count_key, retry_delay + ONE_HOUR, error_count
|
95
|
+
end
|
96
|
+
|
82
97
|
def uniqueness_key(args)
|
83
98
|
[
|
84
99
|
KEY_PREFIX,
|
@@ -99,7 +114,7 @@ module Services
|
|
99
114
|
end
|
100
115
|
|
101
116
|
def retry_delay
|
102
|
-
(
|
117
|
+
(error_count ** 3) + 5
|
103
118
|
end
|
104
119
|
end
|
105
120
|
end
|
data/lib/services/version.rb
CHANGED