pheromone 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +3 -1
- data/lib/pheromone/options_validator.rb +6 -5
- data/lib/pheromone/version.rb +2 -1
- data/lib/pheromone.rb +1 -2
- metadata +2 -3
- data/lib/pheromone/setup/waterdrop.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db7a630ce00647c2357d8e4bea2094bd9c286168
|
4
|
+
data.tar.gz: 2a7675d608b4da552e27a901ba052509553d3f8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438cd1c71c5244fe4e5f8b1f0340f77ccf6b2b4b3302f201fa41b3bb5d692d11cfd6afcfa199a993a4611c2e3ef9f341edcc98899fcee89db00dd941a25e6eae
|
7
|
+
data.tar.gz: 0366406cf8098a29318d93b4571d4f6667fbba169b9f7885a868da030099d46efba1e72d87b0392493649c8f9aaa7bed1c17a76ef1661316d45474aaea630aaa
|
data/CODE_OF_CONDUCT.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Pheromone
|
2
2
|
|
3
|
-
|
3
|
+
Pheromones are chemical substances secreted from glands and used as a means of communication.
|
4
|
+
|
5
|
+
`pheromone` is a mixin to easily send `ActiveRecord` updates to Kafka whenever there is a model update and/or create.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# validate message options provided to publish method in Publishable concern
|
2
3
|
class OptionsValidator
|
3
|
-
ACCEPTED_EVENT_TYPES =
|
4
|
+
ACCEPTED_EVENT_TYPES = %i(create update).freeze
|
4
5
|
|
5
6
|
def initialize(message_options)
|
6
7
|
@errors = {}
|
@@ -34,13 +35,13 @@ class OptionsValidator
|
|
34
35
|
event_types = options[:event_types]
|
35
36
|
next true unless event_types
|
36
37
|
event_types.present? &&
|
37
|
-
|
38
|
-
|
38
|
+
event_types.is_a?(Array) &&
|
39
|
+
(event_types - ACCEPTED_EVENT_TYPES).empty?
|
39
40
|
end
|
40
41
|
|
41
42
|
add_error_message(
|
42
|
-
|
43
|
-
|
43
|
+
:event_types,
|
44
|
+
"Event types must be a non-empty array with types #{ACCEPTED_EVENT_TYPES.join(',')}"
|
44
45
|
)
|
45
46
|
end
|
46
47
|
|
data/lib/pheromone/version.rb
CHANGED
data/lib/pheromone.rb
CHANGED
@@ -23,13 +23,12 @@ require 'active_support'
|
|
23
23
|
# To control how the model is serialized before being published to kafka
|
24
24
|
# either provide a Serializer via the `serializer` key or a callback or instance
|
25
25
|
# method name via the `message` key
|
26
|
-
|
27
26
|
module Pheromone
|
28
27
|
extend ActiveSupport::Concern
|
29
28
|
|
30
29
|
# class methods for the model including Publishable
|
31
30
|
module ClassMethods
|
32
|
-
def publish(message_options
|
31
|
+
def publish(message_options)
|
33
32
|
errors = OptionsValidator.new(message_options).validate
|
34
33
|
raise "Errors: #{errors}" unless errors.empty?
|
35
34
|
__send__(:after_commit, proc { dispatch_messages(message_options: message_options) })
|
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.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankita Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -135,7 +135,6 @@ files:
|
|
135
135
|
- bin/setup
|
136
136
|
- lib/pheromone.rb
|
137
137
|
- lib/pheromone/options_validator.rb
|
138
|
-
- lib/pheromone/setup/waterdrop.rb
|
139
138
|
- lib/pheromone/version.rb
|
140
139
|
homepage: https://github.com/ankitagupta12/pheromone
|
141
140
|
licenses:
|
@@ -1,7 +0,0 @@
|
|
1
|
-
WaterDrop.setup do |config|
|
2
|
-
config.send_messages = true
|
3
|
-
config.connection_pool_size = ENV['KAFKA_CONNECTION_POOL_SIZE'] || 20
|
4
|
-
config.connection_pool_timeout = ENV['KAFKA_CONNECTION_POOL_TIMEOUT'] || 1
|
5
|
-
config.kafka.hosts = (ENV['KAFKA_HOSTS'] || '').split(',')
|
6
|
-
config.raise_on_failure = true
|
7
|
-
end
|