alephant-broker 3.18.0 → 3.19.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: c7359058509b2fff49fd7a29c3425c713c6c0738
4
- data.tar.gz: e42c65579c05d327a18a6d5a2991c53d2ed81dd7
3
+ metadata.gz: f210f7897e17ccce5f81abe391c038f1c8ad1ce0
4
+ data.tar.gz: 9aeac99c27ba61568542e30c6c1fbf1a39861c97
5
5
  SHA512:
6
- metadata.gz: 87fe78ddd8702e94d9b4a981a1770fb0a55c0e4a90ea6ed8c9f80e9927249b830c52ae94f0aa38655a2c5237cc94d7a0dc83e01c4b2714551e72f46ebc803c0a
7
- data.tar.gz: be68d83eee04548185a8880b569ba4f010b2fca364d4751c0ba8c6922fe65f4ad493fe52abd3e827ff771f72c83c9dea37b6f327a4ab0d7110cd34bff1f96cb1
6
+ metadata.gz: c9ae2a9cf2146b7fb9eb32fd2c69c12851b74709d7883492f75fbbbb6f0e786765c1aed45e03a021bbd378fc761ab233db5736b46b3768d32fcb4997114c15e4
7
+ data.tar.gz: 97d0cb77082e460f93627c21da6ffafa24584227e7701129efe9938c74e16ad4a536c5a11b700da09fbf001e73936d72b04bd5fa6e14da92ca669398c62579a4
@@ -1 +1 @@
1
- 2.3
1
+ 2.3.0
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.3"
3
+ - "2.3.0"
4
+ - "2.5.1"
5
+ - "jruby-1.7.23"
4
6
  - "jruby-9.1.17.0"
5
7
  notifications:
6
8
  email:
@@ -11,7 +11,7 @@ module Alephant
11
11
  DEFAULT_TTL = 10
12
12
 
13
13
  def initialize(obj)
14
- logger.info(event: 'SettingCachedObject',
14
+ logger.debug(event: 'SettingCachedObject',
15
15
  content: obj,
16
16
  method: "#{self.class}#initialize")
17
17
 
@@ -19,7 +19,7 @@ module Alephant
19
19
  end
20
20
 
21
21
  def update(obj)
22
- logger.info(event: 'UpdatingCachedObject',
22
+ logger.debug(event: 'UpdatingCachedObject',
23
23
  old_content: @s3_obj,
24
24
  new_content: obj,
25
25
  method: "#{self.class}#update")
@@ -31,14 +31,14 @@ module Alephant
31
31
  time = metadata[:'head_Last-Modified']
32
32
  Time.parse(time)
33
33
  rescue TypeError, ArgumentError => error
34
- logger.info(event: 'ErrorCaught', method: "#{self.class}#updated", error: error)
34
+ logger.error(event: 'CachedObjectLastModifiedError', method: "#{self.class}#updated", error: error)
35
35
  Time.now
36
36
  end
37
37
 
38
38
  def ttl
39
39
  Integer(metadata[:ttl] || metadata['ttl'])
40
40
  rescue TypeError => error
41
- logger.info(event: 'ErrorCaught', method: "#{self.class}#ttl", error: error)
41
+ logger.error(event: 'NonIntegerTTLError', method: "#{self.class}#ttl", error: error)
42
42
  Integer(Broker.config[:revalidate_cache_ttl] || DEFAULT_TTL)
43
43
  end
44
44
 
@@ -11,7 +11,10 @@ module Alephant
11
11
 
12
12
  def initialize
13
13
  if config_endpoint.nil?
14
- logger.debug 'Broker::Cache::Client#initialize: No config endpoint, NullClient used'
14
+ logger.error(
15
+ method: 'Broker::Cache::Client#initialize',
16
+ message: 'No config endpoint, NullClient used'
17
+ )
15
18
  logger.metric 'NoConfigEndpoint'
16
19
  @client = NullClient.new
17
20
  else
@@ -23,22 +26,27 @@ module Alephant
23
26
  versioned_key = versioned(key)
24
27
  result = @client.get(versioned_key)
25
28
 
26
- logger.info("Broker::Cache::Client#get key: #{versioned_key} - #{result ? 'hit' : 'miss'}")
29
+ logger.debug(
30
+ method: 'Broker::Cache::Client#get',
31
+ key: versioned_key,
32
+ result: result ? 'hit' : 'miss'
33
+ )
27
34
  logger.metric('GetKeyMiss') unless result
28
35
 
29
36
  return result if result
30
37
 
31
38
  set(key, yield) if block_given?
32
- rescue StandardError => error
33
- logger.info(event: 'ErrorCaught', method: "#{self.class}#get", error: error)
34
- yield if block_given?
35
39
  end
36
40
 
37
41
  def set(key, value, custom_ttl = nil)
38
42
  versioned_key = versioned(key)
39
43
  set_ttl = custom_ttl || ttl
40
44
 
41
- logger.info("#{self.class}#set - key: #{versioned_key}, ttl: #{set_ttl}")
45
+ logger.debug(
46
+ method: "#{self.class}#set",
47
+ key: versioned_key,
48
+ ttl: set_ttl
49
+ )
42
50
 
43
51
  @client.set(versioned_key, value, set_ttl)
44
52
 
@@ -19,11 +19,19 @@ module Alephant
19
19
  @load_strategy.load(component_meta)
20
20
  )
21
21
  rescue Alephant::Broker::Errors::ContentNotFound => e
22
- logger.warn "Broker.ComponentFactory.create: Exception raised (ContentNotFound) for #{component_meta.component_key}"
22
+ logger.error(
23
+ method: 'Broker.ComponentFactory.create',
24
+ message: 'Exception raised (ContentNotFound)',
25
+ component_key: component_meta.component_key
26
+ )
23
27
  logger.metric "ContentNotFound"
24
28
  ErrorComponent.new(component_meta, 404, e)
25
29
  rescue => e
26
- logger.warn "Broker.ComponentFactory.create: Exception raised (#{e.message}, #{e.backtrace.join('\n')})"
30
+ logger.error(
31
+ method: 'Broker.ComponentFactory.create',
32
+ message: e.message,
33
+ backtrace: e.backtrace.join('\n')
34
+ )
27
35
  logger.metric "ExceptionRaised"
28
36
  ErrorComponent.new(component_meta, 500, e)
29
37
  end
@@ -60,8 +60,12 @@ module Alephant
60
60
 
61
61
  def parse(json)
62
62
  ::JSON.parse(json)
63
- rescue ::JSON::ParserError => e
64
- logger.warn "Broker.environment#data: ParserError"
63
+ rescue ::JSON::ParserError => error
64
+ logger.error(
65
+ method: 'Broker.environment#data',
66
+ message: 'ParserError',
67
+ error: error
68
+ )
65
69
  logger.metric "JSONParserError"
66
70
  nil
67
71
  end
@@ -21,8 +21,9 @@ module Alephant
21
21
 
22
22
  def load(component_meta)
23
23
  fetch_object(component_meta)
24
- rescue
25
- logger.metric "CacheMiss"
24
+ rescue StandardError => error
25
+ logger.error(method: "#{self.class}#load", error: error)
26
+ logger.metric 'HTTPCacheMiss'
26
27
  cache.set(component_meta.component_key, content(component_meta))
27
28
  end
28
29
 
@@ -16,8 +16,8 @@ module Alephant
16
16
  def fetch
17
17
  Alephant::Broker::Cache::CachedObject.new(s3.get(s3_path))
18
18
  rescue Aws::S3::Errors::NoSuchKey, InvalidCacheKey => error
19
- logger.info(event: 'ErrorCaught', method: "#{self.class}#fetch", error: error)
20
- logger.metric('S3InvalidCacheKey')
19
+ logger.error(event: 'InvalidCacheKeyErrorCaught', method: "#{self.class}#fetch", error: error)
20
+ logger.metric 'S3InvalidCacheKey'
21
21
  raise Alephant::Broker::Errors::ContentNotFound
22
22
  end
23
23
 
@@ -16,11 +16,11 @@ module Alephant
16
16
  def refresh
17
17
  inflight = cache.get(inflight_cache_key)
18
18
 
19
- logger.info(event: 'Inflight?', cache_val: inflight, method: "#{self.class}#refresh")
19
+ logger.debug(event: 'Inflight?', cache_val: inflight, method: "#{self.class}#refresh")
20
20
 
21
21
  return if inflight
22
22
 
23
- logger.info(event: 'QueueMessage', message: message, method: "#{self.class}#refresh")
23
+ logger.debug(event: 'QueueMessage', message: message, method: "#{self.class}#refresh")
24
24
 
25
25
  client.send_message(
26
26
  queue_url: queue_url,
@@ -44,7 +44,10 @@ module Alephant
44
44
 
45
45
  def cached_object(component_meta)
46
46
  cache.get(component_meta.component_key) do
47
- logger.info(msg: "#{self.class}#cached_object - No cache so loading and adding cache object")
47
+ logger.debug(
48
+ method: "#{self.class}#cached_object",
49
+ message: 'No cache so loading and adding cache object'
50
+ )
48
51
  Fetcher.new(component_meta).fetch
49
52
  end
50
53
  end
@@ -74,16 +77,21 @@ module Alephant
74
77
  end
75
78
 
76
79
  def cache_new_content(component_meta, new_content)
77
- logger.info(event: 'NewContentFromS3',
78
- key: component_meta.component_key,
79
- val: new_content,
80
- method: "#{self.class}#refresh_content")
80
+ logger.debug(
81
+ event: 'NewContentFromS3',
82
+ key: component_meta.component_key,
83
+ val: new_content,
84
+ method: "#{self.class}#refresh_content"
85
+ )
81
86
 
82
87
  cache.set(component_meta.component_key, new_content)
83
88
  end
84
89
 
85
- def refresh_content(component_meta)
86
- logger.info(msg: "#{self.class}#refresh_content - Loading new content from thread")
90
+ def refresh_content(component_meta)
91
+ logger.debug(
92
+ method: "#{self.class}#refresh_content",
93
+ message: 'Loading new content from thread',
94
+ )
87
95
 
88
96
  Refresher.new(component_meta).refresh
89
97
  end
@@ -61,7 +61,7 @@ module Alephant
61
61
  @cached = false
62
62
  s3.get s3_path(component_meta)
63
63
  rescue Aws::S3::Errors::NoSuchKey, InvalidCacheKey
64
- logger.metric "S3InvalidCacheKey"
64
+ logger.metric 'S3NoSuchKey'
65
65
  raise Alephant::Broker::Errors::ContentNotFound
66
66
  end
67
67
 
@@ -18,7 +18,10 @@ module Alephant
18
18
  )
19
19
  rescue InvalidAssetId
20
20
  logger.metric "InvalidAssetId"
21
- logger.error "Broker.Request.Asset.initialize: Exception raised (InvalidAssetId)"
21
+ logger.error(
22
+ method: 'Broker.Request.Asset.initialize',
23
+ message: 'Exception raised (InvalidAssetId)'
24
+ )
22
25
  end
23
26
 
24
27
  private
@@ -16,11 +16,14 @@ module Alephant
16
16
  env.options.fetch("batch_id", nil)
17
17
  end
18
18
 
19
- logger.info "Request::Batch#initialize: id: #{batch_id}"
19
+ logger.debug(
20
+ method: "Request::Batch#initialize",
21
+ id: batch_id,
22
+ )
20
23
 
21
24
  @component_factory = component_factory
22
25
 
23
- @components = env.post? ? components_post(env) : components_get(env)
26
+ @components = env.post? ? components_post(env) : components_get(env)
24
27
  end
25
28
 
26
29
  private
@@ -34,7 +34,10 @@ module Alephant
34
34
 
35
35
  def log
36
36
  logger.metric "BrokerResponse#{status}"
37
- logger.info "Broker: Component loaded! #{details} (200)"
37
+ logger.info(
38
+ message: 'Asset component loaded',
39
+ status: status
40
+ )
38
41
  end
39
42
  end
40
43
  end
@@ -10,9 +10,9 @@ module Alephant
10
10
  attr_reader :components, :batch_id
11
11
 
12
12
  def initialize(components, batch_id, request_env)
13
- @components = components
14
- @batch_id = batch_id
15
- @status = self.class.component_not_modified(batch_response_headers, request_env) ? 304 : 200
13
+ @components = components
14
+ @batch_id = batch_id
15
+ @status = self.class.component_not_modified(batch_response_headers, request_env) ? 304 : 200
16
16
 
17
17
  super(@status, "application/json", request_env)
18
18
 
@@ -27,7 +27,10 @@ module Alephant
27
27
  private
28
28
 
29
29
  def json
30
- logger.info "Broker: Batch load started (#{batch_id})"
30
+ logger.debug(
31
+ message: 'Broker: Batch load started',
32
+ batch_id: batch_id
33
+ )
31
34
  components.map do |component|
32
35
  {
33
36
  "component" => component.id,
@@ -39,7 +42,10 @@ module Alephant
39
42
  headers["sequence_id"] = component.headers["X-Sequence"] if component.headers["X-Sequence"]
40
43
  end
41
44
  end.tap do
42
- logger.info "Broker: Batch load done (#{batch_id})"
45
+ logger.debug(
46
+ message: 'Broker: Batch load completed',
47
+ batch_id: batch_id
48
+ )
43
49
  logger.metric "BrokerBatchLoadCount"
44
50
  end
45
51
  end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Broker
3
- VERSION = "3.18.0".freeze
3
+ VERSION = "3.19.0".freeze
4
4
  end
5
5
  end
@@ -115,7 +115,7 @@ describe Alephant::Broker::Application do
115
115
  context "when requesting an unmodified response" do
116
116
  let(:path) { "/components/batch" }
117
117
  let(:content_type) { "application/json" }
118
- let(:etag) { '"34774567db979628363e6e865127623f"' }
118
+ let(:etag) { '"8d2f79a98b0e0c1fbcca34850f2c7f17"' }
119
119
 
120
120
  before do
121
121
  post(path, batch_json,
@@ -186,7 +186,7 @@ describe Alephant::Broker::Application do
186
186
  context "when requesting an unmodified response with GET" do
187
187
  let(:path) { "/components/batch?batch_id=baz&components[ni_council_results_table][component]=ni_council_results_table&components[ni_council_results_table][options][foo]=bar&components[ni_council_results_table_no_options][component]=ni_council_results_table" }
188
188
  let(:content_type) { "application/json" }
189
- let(:etag) { '"34774567db979628363e6e865127623f"' }
189
+ let(:etag) { '"8d2f79a98b0e0c1fbcca34850f2c7f17"' }
190
190
 
191
191
  before do
192
192
  get(
@@ -174,7 +174,7 @@ describe Alephant::Broker::Application do
174
174
  end
175
175
 
176
176
  it "should have ETag cache header" do
177
- expect(last_response.headers["ETag"]).to eq('"34774567db979628363e6e865127623f"')
177
+ expect(last_response.headers["ETag"]).to eq('"8d2f79a98b0e0c1fbcca34850f2c7f17"')
178
178
  end
179
179
 
180
180
  it "should have most recent Last-Modified header" do
@@ -223,7 +223,7 @@ describe Alephant::Broker::Application do
223
223
  end
224
224
 
225
225
  it "should have ETag cache header" do
226
- expect(last_response.headers["ETag"]).to eq('"34774567db979628363e6e865127623f"')
226
+ expect(last_response.headers["ETag"]).to eq('"8d2f79a98b0e0c1fbcca34850f2c7f17"')
227
227
  end
228
228
 
229
229
  it "should have most recent Last-Modified header" do
@@ -269,7 +269,7 @@ describe Alephant::Broker::Application do
269
269
  end
270
270
 
271
271
  it "should have ETag cache header" do
272
- expect(last_response.headers["ETag"]).to eq('"34774567db979628363e6e865127623f"')
272
+ expect(last_response.headers["ETag"]).to eq('"8d2f79a98b0e0c1fbcca34850f2c7f17"')
273
273
  end
274
274
 
275
275
  it "should have most recent Last-Modified header" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.18.0
4
+ version: 3.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BBC News
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-01 00:00:00.000000000 Z
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -432,7 +432,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
432
432
  version: '0'
433
433
  requirements: []
434
434
  rubyforge_project:
435
- rubygems_version: 2.6.14
435
+ rubygems_version: 2.5.1
436
436
  signing_key:
437
437
  specification_version: 4
438
438
  summary: Brokers requests for alephant components