waterdrop 0.1.13 → 0.2.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: 47faf12d9fbcb7cebc0b764ecace5eb3de8bb0c1
4
- data.tar.gz: 2bd185c502c8b3103c900c116dc0f0534fcd4ba9
3
+ metadata.gz: 0f15e7e19f6c653cae48eed591c3036b9813c6de
4
+ data.tar.gz: 7faded565baae3e1dc796d7e87b5591181a450d4
5
5
  SHA512:
6
- metadata.gz: d42b8147179daf3c6b767334ffee0f46ed30d852c74a6b85e7e8af36fe8b4802c34f57d046dada12ce0786fe697ca7b075ece78c9439bd2162933b9c71a83bf3
7
- data.tar.gz: a2ec57ba800cf3fc8f8bc7c2e48b5287b4c198b7e82d72efa6655403366f15d94c61754dbeece5eb1a4e86dc255be40eef233000f7d4d1038d8e50b94193220a
6
+ metadata.gz: 7f4f66bad01e5e24102130f5c7fbd30bf256480f57e4dc4764f9093949c94c8c1fac0b1f4259dedafb38e76e46d1b1ca78efa4550e54964b3928ab6a60fed929
7
+ data.tar.gz: b254e0081368a53e68cf0c12648ec7d6db4596f2735f4c1cfcdebad0323f11b99722adb6845a0953ef68b1330b77e85a3a1969304fb8712ec11719ddcf786bf2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.3.0
data/.travis.yml CHANGED
@@ -2,5 +2,6 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.7
4
4
  - 2.2.3
5
+ - 2.3.0
5
6
  script:
6
7
  - bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # WaterDrop changelog
2
2
 
3
+ ## 0.2.0
4
+ - Version dump - this WaterDrop version no longer relies on Aspector to work
5
+ - #17 - Logger for Aspector - WaterDrop no longer depends on Aspector
6
+ - #8 - add send date as a default value added to a message - wontfix. Should be implemented on a message level since WaterDrop just transports messages without adding additional stuff.
7
+ - #11 - same as above
8
+
3
9
  ## 0.1.13
4
10
  - Resolved bug #15. When you use waterdrop in aspect way, message will be automatically parse to JSON.
5
11
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waterdrop (0.1.13)
5
- aspector
4
+ waterdrop (0.2.0)
6
5
  bundler
7
6
  connection_pool
8
7
  null-logger
@@ -25,15 +24,14 @@ GEM
25
24
  adamantium (0.2.0)
26
25
  ice_nine (~> 0.11.0)
27
26
  memoizable (~> 0.4.0)
28
- aspector (0.14.0)
29
- ast (2.1.0)
27
+ ast (2.2.0)
30
28
  astrolabe (1.3.1)
31
29
  parser (~> 2.2)
32
30
  axiom-types (0.1.1)
33
31
  descendants_tracker (~> 0.0.4)
34
32
  ice_nine (~> 0.11.0)
35
33
  thread_safe (~> 0.3, >= 0.3.1)
36
- brakeman (3.1.3)
34
+ brakeman (3.1.4)
37
35
  erubis (~> 2.6)
38
36
  fastercsv (~> 1.5)
39
37
  haml (>= 3.0, < 5.0)
@@ -85,9 +83,9 @@ GEM
85
83
  thread_safe (~> 0.3, >= 0.3.1)
86
84
  method_source (0.8.2)
87
85
  minitest (5.8.3)
88
- mongo (2.2.0)
86
+ mongo (2.2.1)
89
87
  bson (~> 4.0)
90
- mongoid (5.0.1)
88
+ mongoid (5.0.2)
91
89
  activemodel (~> 4.0)
92
90
  mongo (~> 2.1)
93
91
  origin (~> 2.1)
@@ -156,7 +154,7 @@ GEM
156
154
  sexp_processor (~> 4.0)
157
155
  ruby_parser (3.7.2)
158
156
  sexp_processor (~> 4.1)
159
- rubycritic (2.3.0)
157
+ rubycritic (2.4.0)
160
158
  flay (= 2.6.1)
161
159
  flog (= 4.3.2)
162
160
  parser (>= 2.2.0, < 3.0)
@@ -212,4 +210,4 @@ DEPENDENCIES
212
210
  waterdrop!
213
211
 
214
212
  BUNDLED WITH
215
- 1.10.6
213
+ 1.11.2
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Code Climate](https://codeclimate.com/github/karafka/waterdrop/badges/gpa.svg)](https://codeclimate.com/github/karafka/waterdrop)
5
5
  [![Gem Version](https://badge.fury.io/rb/waterdrop.svg)](http://badge.fury.io/rb/waterdrop)
6
6
 
7
- Gem used to send messages to Kafka in a standard and in an aspect way.
7
+ Gem used to send messages to Kafka in an easy way.
8
8
 
9
9
  ## Installation
10
10
 
@@ -64,7 +64,7 @@ end
64
64
 
65
65
  ### Creating and sending standard messages
66
66
 
67
- To send Kafka messages, you don't need to use aspects, you can create and send messages directly:
67
+ To send Kafka messages, just create and send messages directly:
68
68
 
69
69
  ```ruby
70
70
  message = WaterDrop::Message.new('topic', 'message')
@@ -78,86 +78,16 @@ message that you want to send should be either binary or stringified (to_s, to_j
78
78
 
79
79
  ### Using aspects to handle messages
80
80
 
81
- WaterDrop uses [Aspector](https://github.com/gcao/aspector) to allow aspect oriented messages hookup. If you need extensive details about aspector usage, please refer to the [examples](https://github.com/gcao/aspector/tree/master/examples) directory of this project.
82
-
83
- In general aspects allows adding additional behavior to existing code without modifying the code itself. This way we can create and send messages, without "polluting" the business logic with it.
84
-
85
- All the WaterDrop aspects accept following parameters:
86
-
87
- | Option | Value type | Description |
88
- |-------------------------|-----------------------|------------------------------------------------|
89
- | ClassName | Class | Class to which we want to hook |
90
- | method: :method_name | Symbol, Array<Symbol> | Method (or methods) to which we want to hook |
91
- | topic: 'karafka_topic' | String, Symbol | Kafka topic to which we will send the message |
92
-
93
- There also a *message*, *after_message* and *before_message* proc parameter that will be evaluated in the methods object context.
94
-
95
- **Note**: If you use waterdrop in aspect way, the message will be parsed to JSON as default. If you want to change this behaviour, you must override WaterDrop::Aspects::Formatter class.
96
- #### Before aspects hookup
97
-
98
- ```ruby
99
- WaterDrop::Aspects::BeforeAspect.apply(
100
- ClassName,
101
- method: :run,
102
- topic: 'karafka_topic',
103
- message: -> { any_class_name_instance_method }
104
- )
105
- ```
106
-
107
- now each time before you run:
108
-
109
- ```ruby
110
- ClassName.new.run
111
- ```
112
-
113
- a message with the given message will be send to Kafka.
114
-
115
- #### After aspects hookup
116
-
117
- ```ruby
118
- WaterDrop::Aspects::AfterAspect.apply(
119
- ClassName,
120
- method: :run,
121
- topic: 'karafka_topic',
122
- message: ->(result) { "This is result of method run: #{result}" }
123
- )
124
- ```
125
-
126
- now each time after you run:
127
-
128
- ```ruby
129
- ClassName.new.run
130
- ```
131
-
132
- a message with the given message will be send to Kafka.
133
-
134
- #### Around aspects hookup
135
-
136
- ```ruby
137
- WaterDrop::Aspects::AroundAspect.apply(
138
- ClassName,
139
- method: :run,
140
- topic: 'karafka_topic',
141
- before_message: -> { any_class_name_instance_method },
142
- after_message: ->(result) { "This is result of method run: #{result}" }
143
- )
144
- ```
145
-
146
- now each time you run:
147
-
148
- ```ruby
149
- ClassName.new.run
150
- ```
151
-
152
- a message with the given message will be send before and after the method execution.
81
+ WaterDrop no longer depends on [Aspector](https://github.com/gcao/aspector). Please refer to [Aspector](https://github.com/gcao/aspector) documentation if you want to handle messaging in an aspect way.
153
82
 
154
83
  ## References
155
84
 
156
85
  * [Karafka framework](https://github.com/karafka/karafka)
157
86
  * [Waterdrop](https://github.com/karafka/waterdrop)
158
- * [Sidekiq Glass](https://github.com/karafka/sidekiq-glass)
87
+ * [Worker Glass](https://github.com/karafka/worker-glass)
159
88
  * [Envlogic](https://github.com/karafka/envlogic)
160
89
  * [Null Logger](https://github.com/karafka/null-logger)
90
+ * [Aspector](https://github.com/gcao/aspector)
161
91
  * [WaterDrop Travis CI](https://travis-ci.org/karafka/waterdrop)
162
92
  * [WaterDrop Code Climate](https://codeclimate.com/github/karafka/waterdrop)
163
93
 
@@ -1,5 +1,5 @@
1
1
  # WaterDrop library
2
2
  module WaterDrop
3
3
  # Current WaterDrop version
4
- VERSION = '0.1.13'.freeze
4
+ VERSION = '0.2.0'.freeze
5
5
  end
data/lib/waterdrop.rb CHANGED
@@ -7,7 +7,6 @@
7
7
  pathname
8
8
  json
9
9
  poseidon
10
- aspector
11
10
  forwardable
12
11
  connection_pool
13
12
  null_logger
@@ -22,11 +21,6 @@ base_path = File.dirname(__FILE__) + '/water_drop'
22
21
  pool
23
22
  config
24
23
  message
25
- aspects/base_aspect
26
- aspects/formatter
27
- aspects/after_aspect
28
- aspects/around_aspect
29
- aspects/before_aspect
30
24
  ).each { |lib| require "#{base_path}/#{lib}" }
31
25
 
32
26
  # WaterDrop library
data/waterdrop.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'rake'
3
+
4
4
  require 'water_drop/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
@@ -10,13 +10,12 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Maciej Mensfeld', 'Pavlo Vavruk']
11
11
  spec.email = %w( maciej@mensfeld.pl pavlo.vavruk@gmail.com )
12
12
  spec.homepage = 'https://github.com/karafka/waterdrop'
13
- spec.summary = %q{ Kafka messages with aspects made easy! }
13
+ spec.summary = %q{ Kafka messaging made easy! }
14
14
  spec.description = spec.summary
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.add_dependency 'bundler', '>= 0'
18
18
  spec.add_dependency 'rake', '>= 0'
19
- spec.add_dependency 'aspector', '>= 0'
20
19
  spec.add_dependency 'poseidon', '>= 0'
21
20
  spec.add_dependency 'connection_pool', '>= 0'
22
21
  spec.add_dependency 'null-logger'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterdrop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-14 00:00:00.000000000 Z
12
+ date: 2015-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -39,20 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: aspector
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: poseidon
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +81,7 @@ dependencies:
95
81
  - - ">="
96
82
  - !ruby/object:Gem::Version
97
83
  version: '0'
98
- description: Kafka messages with aspects made easy!
84
+ description: Kafka messaging made easy!
99
85
  email:
100
86
  - maciej@mensfeld.pl
101
87
  - pavlo.vavruk@gmail.com
@@ -113,11 +99,6 @@ files:
113
99
  - MIT-LICENCE
114
100
  - README.md
115
101
  - Rakefile
116
- - lib/water_drop/aspects/after_aspect.rb
117
- - lib/water_drop/aspects/around_aspect.rb
118
- - lib/water_drop/aspects/base_aspect.rb
119
- - lib/water_drop/aspects/before_aspect.rb
120
- - lib/water_drop/aspects/formatter.rb
121
102
  - lib/water_drop/config.rb
122
103
  - lib/water_drop/message.rb
123
104
  - lib/water_drop/pool.rb
@@ -145,9 +126,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
126
  version: '0'
146
127
  requirements: []
147
128
  rubyforge_project:
148
- rubygems_version: 2.4.8
129
+ rubygems_version: 2.5.1
149
130
  signing_key:
150
131
  specification_version: 4
151
- summary: Kafka messages with aspects made easy!
132
+ summary: Kafka messaging made easy!
152
133
  test_files: []
153
134
  has_rdoc:
@@ -1,19 +0,0 @@
1
- module WaterDrop
2
- module Aspects
3
- # After method execution aspect
4
- # @example Apply after aspect to a method
5
- # WaterDrop::Aspects::AfterAspect.apply(
6
- # ClassName,
7
- # method: :run,
8
- # topic: 'karafka_topic',
9
- # message: ->(result) { "This is result of method run: #{result}" }
10
- # )
11
- class AfterAspect < BaseAspect
12
- after options[:method], interception_arg: true do |interception, result, *args|
13
- options = interception.options
14
- interception.aspect.handle(self, options, args, options[:message], result)
15
- result
16
- end
17
- end
18
- end
19
- end
@@ -1,22 +0,0 @@
1
- module WaterDrop
2
- module Aspects
3
- # Around method execution aspect
4
- # @example Apply around aspect to a method
5
- # WaterDrop::Aspects::AroundAspect.apply(
6
- # ClassName,
7
- # method: :run,
8
- # topic: 'karafka_topic',
9
- # before_message: -> { any_class_name_instance_method },
10
- # after_message: ->(result) { "This is result of method run: #{result}" }
11
- # )
12
- class AroundAspect < BaseAspect
13
- around options[:method], interception_arg: true do |interception, proxy, *args, &block|
14
- options = interception.options
15
- interception.aspect.handle(self, options, args, options[:before_message])
16
- result = proxy.call(*args, &block)
17
- interception.aspect.handle(self, options, args, options[:after_message], result)
18
- result
19
- end
20
- end
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- module WaterDrop
2
- # Aspects module which include all available aspects
3
- module Aspects
4
- # Base class for all aspects
5
- class BaseAspect < ::Aspector::Base
6
- default private_methods: true
7
-
8
- # @param this is an instance on which we execute aspect (original method caller)
9
- # @param [Hash] options aspect options
10
- # @param [Array] args original method arguments
11
- # @param [Block] message block which we evaluate to get a message that we will send
12
- # @param result original method result
13
- def handle(this, options, args, message, *result)
14
- formatter = Formatter.new(
15
- options,
16
- args,
17
- instance_run(this, result, message)
18
- )
19
-
20
- Message.new(options[:topic], formatter.message).send!
21
- end
22
-
23
- private
24
-
25
- # Method used to change message block binding, so it will be evaluated
26
- # in the caller instance context
27
- # @param this is an instance on which we execute aspect (original method caller)
28
- # @param result original method call result
29
- # @param [Block] message block
30
- def instance_run(this, result, message)
31
- return this.instance_eval(&message) if message.parameters.empty?
32
-
33
- this.instance_exec(result, message) { |res, block| block.call(res.first) }
34
- end
35
- end
36
- end
37
- end
@@ -1,18 +0,0 @@
1
- module WaterDrop
2
- module Aspects
3
- # Before method execution aspect
4
- # @example Apply before aspect to a method
5
- # WaterDrop::Aspects::BeforeAspect.apply(
6
- # ClassName,
7
- # method: :run,
8
- # topic: 'karafka_topic',
9
- # message: -> { any_class_name_instance_method }
10
- # )
11
- class BeforeAspect < BaseAspect
12
- before options[:method], interception_arg: true do |interception, *args|
13
- options = interception.options
14
- interception.aspect.handle(self, options, args, options[:message])
15
- end
16
- end
17
- end
18
- end
@@ -1,25 +0,0 @@
1
- module WaterDrop
2
- module Aspects
3
- # Class used to format message that will be send from an aspect
4
- class Formatter
5
- # @param [Hash] options from an aspect
6
- # @param [Array] args original method arguments
7
- # @param result of execution of the method
8
- def initialize(options, args, result)
9
- @options = options
10
- @args = args
11
- @result = result
12
- end
13
-
14
- # @return [JSON] with formatted message that can be send
15
- def message
16
- {
17
- topic: @options[:topic],
18
- method: @options[:method],
19
- message: @result,
20
- args: @args
21
- }.to_json
22
- end
23
- end
24
- end
25
- end