pheromone 0.3.3 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 579707010487601af25f633bada8a8ffda541ef5
4
- data.tar.gz: c7f027d298ea29b05c4b6ecee8d45dbc3cbbece6
3
+ metadata.gz: 1f7b989beed62ff229ddb99eadf5e30a40e96442
4
+ data.tar.gz: 5d3edfdf9e503ac121bac5ee34ca7953f3c2549e
5
5
  SHA512:
6
- metadata.gz: 59485b3ecea81dbe5a612f3bbea067dea48482c51b9f7f3dbac7d381e2fa5b075b8ceb943a945693ef190165544b425087803f67a015c178cf543693500edd66
7
- data.tar.gz: 55215044cf75ca43ef9678cc92be43eaa3f42feddf3606b8638b98e9c4564e786d3b6de6adb95294ca803eeb0c13643da64018bb75be6c18ab72d63f122dc27c
6
+ metadata.gz: c2f234b68fbf3cd0c7e0e314d8f902e189cb04882661b26c4e5d29aea8a9e3565fd24f596934900f8c2a1699160981d88bdd636d55bd90c0e45d74ece0e41fb0
7
+ data.tar.gz: 588b6d95467b997f447a217d266cd29d6501275c90a8d5e125bee326fcdf9ab04ae37a2074e72c37d72c3634e56c07aed9692539399647ea3c64e72c600c58b3
data/README.md CHANGED
@@ -28,22 +28,19 @@ In order to setup `pheromone`, both `waterdrop` and `pheromone` need to be setup
28
28
 
29
29
  $ bundle exec rails generate pheromone:initializer
30
30
 
31
- This will generate the following file in `config/initializers/pheromone.rb`
31
+ This will generate the following in `config/initializers/pheromone.rb`
32
32
 
33
33
  ```
34
- "Pheromone.setup do |pheromone_config|\n"\
35
- " # pheromone_config.background_processor.name = ':resque / :sidekiq'\n"\
36
- " # pheromone_config.background_processor.klass = 'BackgroundWorker'\n"\
37
- " # pheromone_config.timezone = 'UTC'\n"\
38
- " pheromone_config.message_format = :json\n"\
39
- " WaterDrop.setup do |waterdrop_config|\n"\
40
- " waterdrop_config.send_messages = Rails.env.production?\n"\
41
- " waterdrop_config.connection_pool.size = 20\n"\
42
- " waterdrop_config.connection_pool.timeout = 1\n"\
43
- " waterdrop_config.kafka.seed_brokers = [Rails.env.production? ? ENV['KAFKA_HOST'] : 'localhost:9092']\n"\
44
- " waterdrop_config.raise_on_failure = Rails.env.production?\n"\
45
- " end\n"\
46
- "end"\
34
+ Pheromone.setup do |pheromone_config|
35
+ # pheromone_config.background_processor.name = ':resque / :sidekiq'
36
+ # pheromone_config.background_processor.klass = 'BackgroundWorker'
37
+ # pheromone_config.timezone = 'UTC'
38
+ pheromone_config.message_format = :json
39
+ WaterDrop.setup do |waterdrop_config|
40
+ waterdrop_config.deliver = Rails.env.production?
41
+ waterdrop_config.kafka.seed_brokers = [Rails.env.production? ? ENV['KAFKA_HOST'] : 'localhost:9092']
42
+ end
43
+ end
47
44
  ```
48
45
 
49
46
  Edit this file to modify the default config. The following configuration options are available:
@@ -55,11 +52,6 @@ Edit this file to modify the default config. The following configuration options
55
52
  | background_processor.klass | String | Background processor class name that sends messages to kafka |
56
53
  | timezone_format | String | Valid timezone name for timestamps sent to kafka |
57
54
  | message_format | Symbol | Only supports :json format currently |
58
- | send_messages | Boolean | Should we send messages to Kafka |
59
- | kafka.hosts | Array<String> | Kafka servers hosts with ports |
60
- | connection_pool_size | Integer | Kafka connection pool size |
61
- | connection_pool_timeout | Integer | Kafka connection pool timeout |
62
- | raise_on_failure | Boolean | Should we raise an exception when we cannot send message to Kafka - if false will silently ignore failures (will just ignore them) |
63
55
 
64
56
  The timezone setting will transform any timestamp attributes in the message to the specified format.
65
57
 
@@ -287,22 +279,9 @@ class PublishableModel < ActiveRecord::Base
287
279
  topic: :topic_test,
288
280
  message: ->(obj) { { name: obj.name } },
289
281
  producer_options: {
290
- # The number of retries when attempting to deliver messages. The default is
291
- # 2, so 3 attempts in total, but you can configure a higher or lower number:
292
- max_retries: 5,
293
- # The number of seconds to wait between retries. In order to handle longer
294
- # periods of Kafka being unavailable, increase this number. The default is
295
- # 1 second.
296
- retry_backoff: 5,
297
- # number of acknowledgements that the client should write to before returning
298
- # possible values are :all, 0 or 1 and default behaviour is :all, requiring all
299
- # replicas to acknowledge
300
- required_acks: 1,
301
- # compression can be enabled in order to improve bandwidth, and a minimum number
302
- # of messages that need to be in the buffer before they are compressed can be
303
- # specified using compression threshold
304
- compression_codec: :snappy,
305
- compression_threshold: 10
282
+ key: 'key',
283
+ partition: 1,
284
+ partition_key: 'key'
306
285
  }
307
286
  }
308
287
  ]
@@ -11,11 +11,8 @@ module Pheromone
11
11
  " # pheromone_config.timezone = 'UTC'\n"\
12
12
  " pheromone_config.message_format = :json\n"\
13
13
  " WaterDrop.setup do |waterdrop_config|\n"\
14
- " waterdrop_config.send_messages = Rails.env.production?\n"\
15
- " waterdrop_config.connection_pool.size = 20\n"\
16
- " waterdrop_config.connection_pool.timeout = 1\n"\
14
+ " waterdrop_config.deliver = Rails.env.production?\n"\
17
15
  " waterdrop_config.kafka.seed_brokers = [Rails.env.production? ? ENV['KAFKA_HOST'] : 'localhost:9092']\n"\
18
- " waterdrop_config.raise_on_failure = Rails.env.production?\n"\
19
16
  " end\n"\
20
17
  "end"\
21
18
  )
@@ -1,5 +1,3 @@
1
- require 'waterdrop'
2
-
3
1
  # Encapsulates WaterDrop::Message
4
2
  module Pheromone
5
3
  module Messaging
@@ -14,11 +12,10 @@ module Pheromone
14
12
  attr_reader :topic, :blob, :options, :metadata
15
13
 
16
14
  def send!
17
- ::WaterDrop::Message.new(
18
- topic,
15
+ WaterDrop::SyncProducer.call(
19
16
  MessageFormatter.new(full_message).format,
20
- options
21
- ).send!
17
+ { topic: topic.to_s }.merge!(options)
18
+ )
22
19
  end
23
20
 
24
21
  private
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Pheromone
3
- VERSION = '0.3.3'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
data/lib/pheromone.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'pheromone/publishable'
2
2
  require 'pheromone/config'
3
3
  require 'pheromone/messaging/message'
4
+ require 'rails/railtie'
4
5
  require 'waterdrop'
5
6
 
6
7
  module Pheromone
data/pheromone.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'activerecord', '>= 4.2.5'
25
25
  spec.add_dependency 'bundler', '>= 0'
26
26
  spec.add_dependency 'dry-configurable', '>= 0.5'
27
- spec.add_dependency 'waterdrop', '>= 0.4'
27
+ spec.add_dependency 'waterdrop', '>= 1.0'
28
28
 
29
29
  spec.add_development_dependency 'activesupport', '>= 4.2.5'
30
30
  spec.add_development_dependency 'generator_spec', '~> 0.9.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pheromone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankita Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-19 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0.4'
75
+ version: '1.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0.4'
82
+ version: '1.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: activesupport
85
85
  requirement: !ruby/object:Gem::Requirement