services 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Guardfile +12 -3
- data/lib/services.rb +3 -1
- data/lib/services/base.rb +4 -0
- data/lib/services/logger/null.rb +8 -0
- data/lib/services/modules/call_logger.rb +0 -5
- data/lib/services/version.rb +1 -1
- data/spec/services/configuration_spec.rb +11 -0
- data/spec/spec_helper.rb +3 -3
- data/spec/support/shared.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f848f7e6c1284b6671f565cb1d27d4119cb4a355
|
4
|
+
data.tar.gz: 3dbce97879f9e9768715839d9151fb2e3e0bd3ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c370c5325be285ad139465aeb88b471570de89dd0b791afcb4d18f83cf9505071edb0234c61f13946ed1bee9e2dda0013e5644607747ed04d23f049fd06149d
|
7
|
+
data.tar.gz: 5cfe01abb853bf5b6ac99127fecde95f225b23df823a1d46d6b09bee498a2a7d41f72062ed5d8bc3a07937c0ffda9e0d087e7b61a512fdd3df87076500e4c419
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 4.0.2
|
2
|
+
|
3
|
+
* Add null logger
|
4
|
+
|
5
|
+
## 4.0.1
|
6
|
+
|
7
|
+
* Account for that `redis.multi` can return nil
|
8
|
+
|
9
|
+
## 4.0.0
|
10
|
+
|
11
|
+
* Remove host configuration and controller method
|
12
|
+
|
13
|
+
## 3.1.1
|
14
|
+
|
15
|
+
* Query does not have its own error, raise ArgumentError instead
|
16
|
+
|
17
|
+
## 3.1.0
|
18
|
+
|
19
|
+
* Verify that query ids parameter is not nil
|
20
|
+
|
1
21
|
## 3.0.1
|
2
22
|
|
3
23
|
* Fix for Ruby 2.0
|
data/Guardfile
CHANGED
@@ -15,17 +15,23 @@ module ::Guard
|
|
15
15
|
REDIS_CLI = SPEC_SUPPORT_DIR.join('redis-cli')
|
16
16
|
REDIS_PIDFILE = SPEC_SUPPORT_DIR.join('redis.pid')
|
17
17
|
REDIS_LOGFILE = SPEC_SUPPORT_DIR.join('log', 'redis.log')
|
18
|
+
REDIS_PORT = 6479
|
19
|
+
|
20
|
+
def self.options_to_string(options)
|
21
|
+
options.map { |k, v| "-#{'-' if k.length > 1}#{k} #{v}" }.join(' ')
|
22
|
+
end
|
18
23
|
|
19
24
|
class OnStart
|
20
25
|
def call(guard_class, event, *args)
|
21
|
-
|
26
|
+
options = {
|
22
27
|
daemonize: 'yes',
|
23
28
|
dir: SPEC_SUPPORT_DIR,
|
24
29
|
dbfilename: 'redis.rdb',
|
25
30
|
logfile: REDIS_LOGFILE,
|
26
31
|
pidfile: REDIS_PIDFILE,
|
32
|
+
port: REDIS_PORT
|
27
33
|
}
|
28
|
-
system "#{REDIS_BIN} #{
|
34
|
+
system "#{REDIS_BIN} #{ServicesGemHelpers.options_to_string options}"
|
29
35
|
|
30
36
|
i = 0
|
31
37
|
while !File.exist?(REDIS_PIDFILE)
|
@@ -39,7 +45,10 @@ module ::Guard
|
|
39
45
|
|
40
46
|
class OnStop
|
41
47
|
def call(guard_class, event, *args)
|
42
|
-
|
48
|
+
options = {
|
49
|
+
p: REDIS_PORT
|
50
|
+
}
|
51
|
+
system "#{REDIS_CLI} #{ServicesGemHelpers.options_to_string options} shutdown"
|
43
52
|
|
44
53
|
i = 0
|
45
54
|
while File.exist?(REDIS_PIDFILE)
|
data/lib/services.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'gem_config'
|
2
2
|
|
3
|
+
require_relative 'services/logger/null'
|
4
|
+
|
3
5
|
module Services
|
4
6
|
include GemConfig::Base
|
5
7
|
|
6
8
|
BackgroundProcessorNotFound = Class.new(StandardError)
|
7
9
|
|
8
10
|
with_configuration do
|
9
|
-
has :logger
|
11
|
+
has :logger, default: Services::Logger::Null.new
|
10
12
|
has :redis
|
11
13
|
end
|
12
14
|
end
|
data/lib/services/base.rb
CHANGED
@@ -27,6 +27,10 @@ module Services
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
+
def log(message, meta = {}, severity = 'info')
|
31
|
+
Services.configuration.logger.log message, meta.merge(service: self.class.to_s, id: @id), severity
|
32
|
+
end
|
33
|
+
|
30
34
|
def _split_ids_and_objects(ids_or_objects, klass)
|
31
35
|
ids_or_objects = Array(ids_or_objects)
|
32
36
|
ids, objects = ids_or_objects.grep(Fixnum), ids_or_objects.grep(klass)
|
@@ -28,7 +28,6 @@ module Services
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def call(*args)
|
31
|
-
return super if Services.configuration.logger.nil?
|
32
31
|
unless self.class.call_logging_disabled
|
33
32
|
log "START with args: #{args}", caller: caller
|
34
33
|
start = Time.now
|
@@ -46,10 +45,6 @@ module Services
|
|
46
45
|
|
47
46
|
private
|
48
47
|
|
49
|
-
def log(message, meta = {}, severity = 'info')
|
50
|
-
Services.configuration.logger.log message, meta.merge(service: self.class.to_s, id: @id), severity
|
51
|
-
end
|
52
|
-
|
53
48
|
def exception_message(e)
|
54
49
|
message = "#{e.class}: #{e.message}"
|
55
50
|
e.backtrace.each do |line|
|
data/lib/services/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -17,20 +17,20 @@ SIDEKIQ_PIDFILE = SUPPORT_DIR.join('sidekiq.pid')
|
|
17
17
|
WAIT = 0.5
|
18
18
|
START_TIMEOUT = 5
|
19
19
|
SIDEKIQ_TIMEOUT = 20
|
20
|
+
REDIS_PORT = 6479
|
20
21
|
|
21
22
|
Dir[SUPPORT_DIR.join('**', '*.rb')].each { |f| require f }
|
22
23
|
|
23
|
-
|
24
24
|
Services.configure do |config|
|
25
25
|
config.redis = Redis.new
|
26
26
|
end
|
27
27
|
|
28
28
|
Sidekiq.configure_client do |config|
|
29
|
-
config.redis = { redis:
|
29
|
+
config.redis = { redis: "redis://localhost:#{REDIS_PORT}/0", namespace: 'sidekiq', size: 1 }
|
30
30
|
end
|
31
31
|
|
32
32
|
Sidekiq.configure_server do |config|
|
33
|
-
config.redis = { redis:
|
33
|
+
config.redis = { redis: "redis://localhost:#{REDIS_PORT}/0", namespace: 'sidekiq' }
|
34
34
|
end
|
35
35
|
|
36
36
|
RSpec.configure do |config|
|
data/spec/support/shared.rb
CHANGED
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: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- lib/services/asyncable.rb
|
155
155
|
- lib/services/base.rb
|
156
156
|
- lib/services/logger/file.rb
|
157
|
+
- lib/services/logger/null.rb
|
157
158
|
- lib/services/logger/redis.rb
|
158
159
|
- lib/services/modules/call_logger.rb
|
159
160
|
- lib/services/modules/exception_wrapper.rb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- lib/services/version.rb
|
165
166
|
- services.gemspec
|
166
167
|
- spec/services/base_spec.rb
|
168
|
+
- spec/services/configuration_spec.rb
|
167
169
|
- spec/services/logger/redis_spec.rb
|
168
170
|
- spec/services/modules/call_logger_spec.rb
|
169
171
|
- spec/services/modules/exception_wrapper_spec.rb
|
@@ -197,12 +199,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
199
|
version: '0'
|
198
200
|
requirements: []
|
199
201
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.
|
202
|
+
rubygems_version: 2.4.5
|
201
203
|
signing_key:
|
202
204
|
specification_version: 4
|
203
205
|
summary: A nifty service layer for your Rails app
|
204
206
|
test_files:
|
205
207
|
- spec/services/base_spec.rb
|
208
|
+
- spec/services/configuration_spec.rb
|
206
209
|
- spec/services/logger/redis_spec.rb
|
207
210
|
- spec/services/modules/call_logger_spec.rb
|
208
211
|
- spec/services/modules/exception_wrapper_spec.rb
|