xcflushd 1.0.0.rc2 → 1.0.0

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: 694ae11bc7807759b892802c006f028b0a10013b
4
- data.tar.gz: 6a11f6bc59ceb76f3dae647a0d1be9d985c56591
3
+ metadata.gz: 99f1cb623f33f531541f29169d019be6f8cc16cc
4
+ data.tar.gz: 44ddf936023001785ab6f09a959bc56ad9ea401e
5
5
  SHA512:
6
- metadata.gz: 0196ba49fbbe148073389232a18941af5533e267c16d054d04a62877660fcfe67558027f9077d3b440ce6f6026280742297f2b1884ff091c18488741caf06205
7
- data.tar.gz: 50d187cab468d4546c498a6254d56fa144ac910ce4e7597aa921d43d3c10e82bc7833205f0fe6608d43b062c6ba1c2ea8363ffc47b7289dbc9cb7a6c5f7c5024
6
+ metadata.gz: 4c15f4195eec039d97a9a1626a920b245496460253428ccd3f0117d6bc8153ca30f37c2aebfcb43d1c73f123b71941398950eca58829257277271636babe4990
7
+ data.tar.gz: 5a421824e1e674541a76206f183a7e5ca8af42e464eed2c537974a4ad522a5d2ee895b99a1b3f2f80eb6b11643ef6b4a28bcb5b949c8635b37a5f44ebc876a25
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xcflushd (1.0.0.rc2)
5
- 3scale_client (~> 2.10.0)
4
+ xcflushd (1.0.0)
5
+ 3scale_client (~> 2.10)
6
6
  concurrent-ruby (= 1.0.2)
7
7
  daemons (= 1.2.4)
8
8
  gli (= 2.14.0)
9
9
  hiredis (= 0.6.1)
10
10
  net-http-persistent (= 2.9.4)
11
- redis (= 3.3.1)
11
+ redis (= 3.3.2)
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
@@ -33,13 +33,13 @@ GEM
33
33
  ast (~> 2.2)
34
34
  powerpack (0.1.1)
35
35
  rainbow (2.1.0)
36
- rake (11.2.2)
37
- redis (3.3.1)
36
+ rake (11.3.0)
37
+ redis (3.3.2)
38
38
  rspec (3.5.0)
39
39
  rspec-core (~> 3.5.0)
40
40
  rspec-expectations (~> 3.5.0)
41
41
  rspec-mocks (~> 3.5.0)
42
- rspec-core (3.5.2)
42
+ rspec-core (3.5.4)
43
43
  rspec-support (~> 3.5.0)
44
44
  rspec-expectations (3.5.0)
45
45
  diff-lcs (>= 1.2.0, < 2.0)
@@ -66,7 +66,7 @@ PLATFORMS
66
66
  ruby
67
67
 
68
68
  DEPENDENCIES
69
- bundler (~> 1.12)
69
+ bundler (~> 1.13)
70
70
  fakeredis (~> 0.6.0)
71
71
  rake (~> 11.0)
72
72
  rspec (~> 3.0)
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  ## Description
6
6
 
7
7
  This is the daemon that flushes the data that the gateway side of XC like the
8
- [apicast-xc](https://github.com/3scale/apicast-xc) module running on top of [Apicast](https://github.com/3scale/apicast), stores for reporting and authorizing to 3scale.
8
+ [apicast-xc](https://github.com/3scale/apicast-xc) module running on top of [APIcast](https://github.com/3scale/apicast), stores for reporting and authorizing to 3scale.
9
9
 
10
10
  When you deploy 3scale to a gateway you usually have a request performed to
11
11
  3scale for every request that needs authorization, which introduces latency and
@@ -68,7 +68,7 @@ $ docker run --rm xcflushd bundle exec xcflushd help run
68
68
 
69
69
  You can send the options as params in the `xcflushd` command:
70
70
  ```
71
- $ docker run --rm xcflushd bundle exec xcflushd run --auth-ttl 900 --provider-key my_provider_key --redis 127.0.0.1:6379 --frequency 300 --backend https://su1.3scale.net:443
71
+ $ docker run --rm -it xcflushd bundle exec xcflushd run --auth-ttl 900 --provider-key my_provider_key --redis 127.0.0.1:6379 --frequency 300 --backend https://su1.3scale.net:443
72
72
  ```
73
73
 
74
74
  Please note that the help command will also show you abbreviated flags you can
@@ -88,7 +88,7 @@ $ bundle exec xcflushd help
88
88
 
89
89
  ### Openshift
90
90
 
91
- If what you need is deploying Xcflushd together with Apicast and XC, you can
91
+ If what you need is deploying Xcflushd together with APIcast and XC, you can
92
92
  follow the instructions provided in the [apicast-xc repo](https://github.com/3scale/apicast-xc).
93
93
 
94
94
 
data/docs/design.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ## Description
4
4
 
5
5
  xcflushd is a daemon used together with [XC](https://github.com/3scale/apicast-xc),
6
- which is a module for [Apicast](https://github.com/3scale/apicast), 3scale's
6
+ which is a module for [APIcast](https://github.com/3scale/apicast), 3scale's
7
7
  API Gateway.
8
8
 
9
9
  If you are not familiar with XC yet, we recommend you to start reading its
@@ -61,7 +61,7 @@ in the reports sent to 3scale's backend, and 2) do not have any limits defined.
61
61
  The whole flushing process makes 2 calls to 3scale per application reported.
62
62
  One call to send the report to 3scale, and another one to get the current
63
63
  authorization status. Compare that to making one request for each one that
64
- arrives to the proxy as in the case of Apicast. Imagine that you have 1k rps,
64
+ arrives to the proxy as in the case of APIcast. Imagine that you have 1k rps,
65
65
  and 100 apps. If you define a period of 1 minute for the flushing process, you
66
66
  will be making 200 requests to 3scale's backend per minute instead of 60k.
67
67
 
@@ -3,6 +3,28 @@ require 'logger'
3
3
  module Xcflushd
4
4
  class Logger
5
5
  def self.new(*args)
6
+ # Logging to a IO-like object.
7
+ #
8
+ # When the IO object is a TTY, Ruby sets line buffered mode, which is
9
+ # ok for logs. However, when it is not a TTY, Ruby sets up a buffer
10
+ # of unspecified size that causes applications that write few logs to
11
+ # appear as inactive in the log stream. This is a problem when trying
12
+ # to diagnose issues.
13
+ #
14
+ # Unfortunately Ruby only exposes a couple of limited ways to control
15
+ # the underlying buffering: IO#(f)sync and IO#flush. Apparently the C
16
+ # runtime stdio buffering is replaced by Ruby's own, so there is no
17
+ # point in trying to call setvbuf, and no point either in trying to
18
+ # control a TTY, since that case is fine.
19
+ #
20
+ # Since our logging stream activity is fairly low it's reasonable to
21
+ # use IO#sync for the non TTY case to have (hopefully) a behaviour
22
+ # similar to line-buffered standard I/O.
23
+ #
24
+ # More info on http://tuxdna.in/files/notes/ruby-io.html.
25
+ #
26
+ io = args[0]
27
+ io.sync = true unless io.tty?
6
28
  ::Logger.new(*args)
7
29
  end
8
30
  end
@@ -97,6 +97,8 @@ module Xcflushd
97
97
  end
98
98
  end
99
99
  @logger.info('Exiting')
100
+ rescue SignalException => e
101
+ @logger.fatal("Received unhandled signal #{e.cause}, shutting down")
100
102
  rescue Exception => e
101
103
  @logger.fatal("Unhandled exception #{e.class}, shutting down: #{e.cause} - #{e}")
102
104
  ensure
@@ -157,8 +159,12 @@ module Xcflushd
157
159
 
158
160
  def setup_sighandlers
159
161
  @exit = false
160
- Signal.trap('EXIT') { @exit = true }
161
- Signal.trap('INT') { @exit = true }
162
+ ['HUP', 'USR1', 'USR2'].each do |sig|
163
+ Signal.trap(sig, "SIG_IGN")
164
+ end
165
+ ['EXIT', 'TERM', 'INT'].each do |sig|
166
+ Signal.trap(sig) { @exit = true }
167
+ end
162
168
  end
163
169
  end
164
170
  end
@@ -80,10 +80,12 @@ module Xcflushd
80
80
  # Returns an array of size 2 with a service and the credentials encoded
81
81
  # given a key marked as 'to be flushed' and its suffix.
82
82
  def service_and_creds(key_to_flush, suffix)
83
- escaped_service, escaped_creds =
84
- key_to_flush.sub("#{KEY_TO_FLUSH_PREFIX}#{REPORT_KEY_PREFIX}", '')
85
- .sub(suffix, '')
86
- .split(/(?<!\\),/)
83
+ split_key = key_to_flush.sub("#{KEY_TO_FLUSH_PREFIX}#{REPORT_KEY_PREFIX}", '')
84
+ .sub(suffix, '')
85
+ .split(/(?<!\\),/)
86
+
87
+ escaped_service = split_key.first
88
+ escaped_creds = split_key[1..-1].join(','.freeze)
87
89
 
88
90
  # escaped_service is a string with 'service_id:' followed by the escaped
89
91
  # service ID. escaped_creds starts with 'credentials:' and is followed
@@ -1,3 +1,3 @@
1
1
  module Xcflushd
2
- VERSION = "1.0.0.rc2"
2
+ VERSION = "1.0.0"
3
3
  end
data/xcflushd.gemspec CHANGED
@@ -10,7 +10,11 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["support@3scale.net"]
11
11
 
12
12
  spec.summary = %q{Daemon for flushing XC reports to 3scale.}
13
- spec.description = %q{Daemon for flushing XC reports to 3scale.}
13
+ spec.description = "xcflushd is a daemon that connects to a Redis database " \
14
+ "containing 3scale's XC API Management data and flushes " \
15
+ "it to the 3scale service for cached reporting and " \
16
+ "authorizations. Check https://github.com/3scale/apicast-xc" \
17
+ " for an implementation of a 3scale's XC gateway."
14
18
  spec.homepage = "https://github.com/3scale/xcflushd"
15
19
 
16
20
  spec.license = "Apache-2.0"
@@ -22,15 +26,15 @@ Gem::Specification.new do |spec|
22
26
 
23
27
  spec.required_ruby_version = '>= 2.1.0'
24
28
 
25
- spec.add_runtime_dependency "3scale_client", "~> 2.10.0"
29
+ spec.add_runtime_dependency "3scale_client", "~> 2.10"
26
30
  spec.add_runtime_dependency "gli", "= 2.14.0"
27
- spec.add_runtime_dependency "redis", "= 3.3.1"
31
+ spec.add_runtime_dependency "redis", "= 3.3.2"
28
32
  spec.add_runtime_dependency "hiredis", "= 0.6.1"
29
33
  spec.add_runtime_dependency "concurrent-ruby", "1.0.2"
30
34
  spec.add_runtime_dependency "net-http-persistent", "2.9.4"
31
35
  spec.add_runtime_dependency "daemons", "= 1.2.4"
32
36
 
33
- spec.add_development_dependency "bundler", "~> 1.12"
37
+ spec.add_development_dependency "bundler", "~> 1.13"
34
38
  spec.add_development_dependency "rake", "~> 11.0"
35
39
  spec.add_development_dependency "rspec", "~> 3.0"
36
40
  spec.add_development_dependency "fakeredis", "~> 0.6.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcflushd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Martinez Ruiz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-21 00:00:00.000000000 Z
12
+ date: 2017-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: 3scale_client
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.10.0
20
+ version: '2.10'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 2.10.0
27
+ version: '2.10'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: gli
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 3.3.1
48
+ version: 3.3.2
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 3.3.1
55
+ version: 3.3.2
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: hiredis
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '1.12'
118
+ version: '1.13'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '1.12'
125
+ version: '1.13'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rake
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +193,10 @@ dependencies:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
195
  version: 0.46.0
196
- description: Daemon for flushing XC reports to 3scale.
196
+ description: xcflushd is a daemon that connects to a Redis database containing 3scale's
197
+ XC API Management data and flushes it to the 3scale service for cached reporting
198
+ and authorizations. Check https://github.com/3scale/apicast-xc for an implementation
199
+ of a 3scale's XC gateway.
197
200
  email:
198
201
  - support@3scale.net
199
202
  executables:
@@ -254,12 +257,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
254
257
  version: 2.1.0
255
258
  required_rubygems_version: !ruby/object:Gem::Requirement
256
259
  requirements:
257
- - - ">"
260
+ - - ">="
258
261
  - !ruby/object:Gem::Version
259
- version: 1.3.1
262
+ version: '0'
260
263
  requirements: []
261
264
  rubyforge_project:
262
- rubygems_version: 2.6.4
265
+ rubygems_version: 2.6.8
263
266
  signing_key:
264
267
  specification_version: 4
265
268
  summary: Daemon for flushing XC reports to 3scale.