osbourne 1.1.4 → 1.1.5

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
  SHA256:
3
- metadata.gz: 9aa3421f43348d004bceebe0e3128fe59fdabfae25c3d6080a1f3f83c607b908
4
- data.tar.gz: 2897a8044538c7afd5637d4e37a6b8bf990f208b28135e871b29a7650974677b
3
+ metadata.gz: 5bc30cb744a8d1f61944e06d22366941ac38cb47a403b7326bcae0d42675354b
4
+ data.tar.gz: 763818934b5e711f4d490c79a5e0c23ac9be6cbd405db01d2ff84d566bc89965
5
5
  SHA512:
6
- metadata.gz: 1f8168a4f50a7a79a0b37c5604e828129d4514d83245520a06feedb74990ae85179324e470f8e24009f3ad4a72bbdda2f7a141dd929efeac69708cb40535d51b
7
- data.tar.gz: '05876b12a5e16ebf32351a339a221de15ffd7a1021774c5b373ca0e4af1b2e06f6ab20f07e7500ce373bc634369c80f7bd7ceff098f412fcf7da478794519170'
6
+ metadata.gz: a4747c0fc40a18ec8f4c09dd1bb6f524642d6237f595bf2467313d39dc650886a292e0c546cef3f2ea68c1bb7d360b9336ce24fcec16315dd8a2d4c413b275fc
7
+ data.tar.gz: fa40de44493aa86981222b685da16e9a291e07906a6d743b5e0d85572dee996d502bd6bd75ead9f9d1d5e59036374bf0ab66d56b6d6496f1db2e2cafd9deb03e
@@ -13,6 +13,9 @@ Osbourne.configure do |config|
13
13
  # sent to the dead letter queue
14
14
  # config.max_retry_count = 5
15
15
 
16
+ # The prefix to be used on queues and topics. Useful for environment separation
17
+ # config.prefix = Rails.env
18
+
16
19
  # Amount of time each worker will wait between attempting to fetch messages
17
20
  # config.sleep_time = 15.seconds
18
21
 
@@ -47,5 +47,9 @@ module Osbourne
47
47
  def configure
48
48
  yield config
49
49
  end
50
+
51
+ def prefixer(str)
52
+ [Osbourne.prefix, str].reject(&:blank?).reject(&:nil?).join("_")
53
+ end
50
54
  end
51
55
  end
@@ -48,6 +48,10 @@ module Osbourne
48
48
  def threads_per_worker
49
49
  config.threads_per_worker ||= 5
50
50
  end
51
+
52
+ def prefix
53
+ config.prefix ||= Rails.env
54
+ end
51
55
  end
52
56
  end
53
57
  end
@@ -6,10 +6,11 @@ module Osbourne
6
6
  class MockPubsub
7
7
  class << self
8
8
  def mock_publish(topic, message)
9
+ prefixed_topic = Osbourne.prefixer(topic)
9
10
  parsed_message = parse(message)
10
11
  Osbourne::WorkerBase.descendants.each do |worker|
11
- msg = Osbourne::Test::Message.new(topic: topic, body: parsed_message)
12
- worker.new.process(msg) if worker.config[:topic_names].include? topic
12
+ msg = Osbourne::Test::Message.new(topic: prefixed_topic, body: parsed_message)
13
+ worker.new.process(msg) if worker.config[:topic_names].include? prefixed_topic
13
14
  end
14
15
  end
15
16
 
@@ -4,8 +4,10 @@ module Osbourne
4
4
  class Topic
5
5
  include Services::SNS
6
6
  attr_reader :name
7
+ attr_reader :prefixed_name
7
8
  def initialize(name)
8
9
  @name = name
10
+ @prefixed_name = Osbourne.prefixer(name)
9
11
  arn
10
12
  end
11
13
 
@@ -17,7 +19,7 @@ module Osbourne
17
19
  parsed_message = parse(message)
18
20
  return if Osbourne.test_mode?
19
21
 
20
- Osbourne.logger.info "[PUB] TOPIC: `#{name}` MESSAGE: `#{parsed_message}`"
22
+ Osbourne.logger.info "[PUB] TOPIC: `#{prefixed_name}` MESSAGE: `#{parsed_message}`"
21
23
  sns.publish(topic_arn: arn, message: parsed_message)
22
24
  end
23
25
 
@@ -26,14 +28,14 @@ module Osbourne
26
28
  def ensure_topic
27
29
  return if Osbourne.test_mode?
28
30
 
29
- Osbourne.logger.debug "Ensuring topic `#{name}` exists"
30
- Osbourne.cache.fetch("osbourne_existing_topic_arn_for_#{name}", ex: 1.minute) do
31
- sns.create_topic(name: name).topic_arn
31
+ Osbourne.logger.debug "Ensuring topic `#{prefixed_name}` exists"
32
+ Osbourne.cache.fetch("osbourne_existing_topic_arn_for_#{prefixed_name}", ex: 1.minute) do
33
+ sns.create_topic(name: prefixed_name).topic_arn
32
34
  end
33
35
  end
34
36
 
35
37
  def subscriptions_cache_key
36
- "existing_sqs_subscriptions_for_#{name}"
38
+ "existing_sqs_subscriptions_for_#{prefixed_name}"
37
39
  end
38
40
 
39
41
  def parse(message)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Osbourne
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.5"
5
5
  end
@@ -81,8 +81,8 @@ module Osbourne
81
81
  dead_letter_queue: true,
82
82
  max_retry_count: Osbourne.max_retry_count)
83
83
  self.config = {
84
- topic_names: Array(topics),
85
- queue_name: queue_name,
84
+ topic_names: Array(topics).map {|tp| Osbourne.prefixer(tp) },
85
+ queue_name: Osbourne.prefixer(queue_name),
86
86
  max_batch_size: max_batch_size,
87
87
  max_wait: max_wait,
88
88
  threads: threads,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osbourne
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-25 00:00:00.000000000 Z
11
+ date: 2018-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core