karafka-sidekiq-backend 1.2.0.beta1 → 1.2.0.beta2

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: 16558b17b692066dafda116ac5305f97eb090223c525ef9f7d928421ff035778
4
- data.tar.gz: 47a3e0b1dcc3553077c2144f2e175318ac1de7a2bff40f33501c54361bf369b6
3
+ metadata.gz: 5cbf46f4edac28d13fad77fc120bf92456e37380bcee52718713ad94f4e9a5f2
4
+ data.tar.gz: 5da6e57d3f61b3d2f59410e78c7c94a1a26b04051714f2895f36ce00c2099e8c
5
5
  SHA512:
6
- metadata.gz: 43ea83d99f762fa1d9d709773959fd5c94cba803be58f4f32d19fd1bf080c4ec25d195c72bc874a947af9b4220ea91bfee47e890d229319d8f7607e1da30e0fe
7
- data.tar.gz: 74b9743f1df06af45ca2953e055bd3622693b326ce347f1bf887d8a299c59a1b8c3c3cedbaefb7b76453aee0f788571717a85484934d5cab2578ec0355906310
6
+ metadata.gz: c98cfa129b4733d21fa6fc0491ba522c89c5187fc1d1113b8256e9a980f50dba131353b61e37ee3f9867d8ad6e6a665abb0d2980ec3cff9bcab91fc3dfa9b53f
7
+ data.tar.gz: 63fd8534461a01e418e365f13ad207cfad9d5f7dff24adc09b8b15301e22749b3ad2d49b38ead45a70628722af90d2e36f5d48f3ce1cdadf1783567a9304fc93
data/CHANGELOG.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Karafka Sidekiq Backend
2
2
 
3
- ## 1.2.0.beta1
3
+ ## 1.2.0.beta2
4
4
  - #274 - Rename controllers to consumers
5
5
  - Karafka 1.2 support
6
+ - Parse data before pushing to Sidekiq
6
7
 
7
8
  ## 1.1
8
9
  - Ruby 2.4.2 support
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-sidekiq-backend (1.2.0.beta1)
5
- karafka (>= 1.2.0.beta1)
4
+ karafka-sidekiq-backend (1.2.0.beta2)
5
+ karafka (>= 1.2.0.beta2)
6
6
  sidekiq (>= 4.2)
7
7
 
8
8
  GEM
@@ -63,7 +63,7 @@ GEM
63
63
  concurrent-ruby (~> 1.0)
64
64
  inflecto (0.0.2)
65
65
  json (2.1.0)
66
- karafka (1.2.0.beta1)
66
+ karafka (1.2.0.beta2)
67
67
  activesupport (>= 4.0)
68
68
  dry-configurable (~> 0.7)
69
69
  dry-inflector (~> 0.1.1)
data/README.md CHANGED
@@ -98,12 +98,16 @@ Custom interchangers target issues with non-standard (binary, etc.) data that we
98
98
  ```ruby
99
99
  class Base64Interchanger
100
100
  class << self
101
- def load(params)
102
- Base64.encode64(Marshal.dump(params))
101
+ def load(params_batch)
102
+ params_batch.map do |params|
103
+ Base64.encode64(Marshal.dump(params))
104
+ end
103
105
  end
104
106
 
105
- def parse(params)
106
- Marshal.load(Base64.decode64(params))
107
+ def parse(params_batch)
108
+ params_batch.map do |params|
109
+ Marshal.load(Base64.decode64(params))
110
+ end
107
111
  end
108
112
  end
109
113
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.description = 'Karafka Sidekiq backend for background messages processing'
16
16
  spec.license = 'MIT'
17
17
 
18
- spec.add_dependency 'karafka', '>= 1.2.0.beta1'
18
+ spec.add_dependency 'karafka', '>= 1.2.0.beta2'
19
19
  spec.add_dependency 'sidekiq', '>= 4.2'
20
20
  spec.required_ruby_version = '>= 2.3.0'
21
21
 
@@ -5,20 +5,18 @@ module Karafka
5
5
  # Sidekiq backend that schedules stuff to Sidekiq worker for delayed execution
6
6
  module Sidekiq
7
7
  # Karafka Sidekiq backend version
8
- VERSION = '1.2.0.beta1'
8
+ VERSION = '1.2.0.beta2'
9
9
 
10
10
  # Enqueues the execution of perform method into a worker.
11
11
  # @note Each worker needs to have a class #perform_async method that will allow us to pass
12
12
  # parameters into it. We always pass topic as a first argument and this request
13
13
  # params_batch as a second one (we pass topic to be able to build back the consumer
14
14
  # in the worker)
15
- def call
16
- Karafka.monitor.instrument('backends.sidekiq.process', caller: self) do
15
+ def process
17
16
  topic.worker.perform_async(
18
17
  topic.id,
19
- topic.interchanger.load(params_batch.to_a)
18
+ topic.interchanger.load(params_batch)
20
19
  )
21
- end
22
20
  end
23
21
  end
24
22
  end
@@ -13,22 +13,24 @@ module Karafka
13
13
  # @note Params might not be parsed because of lazy loading feature. If you implement your
14
14
  # own interchanger logic, this method needs to return data that can be converted to
15
15
  # json with default Sidekiqs logic
16
- # @return [Karafka::Params::ParamsBatch] same as input. We assume that our incoming data is
17
- # jsonable-safe and we can rely on a direct Sidekiq encoding logic
16
+ # @return [Karafka::Params::ParamsBatch] parsed params batch. There are too many problems
17
+ # with passing unparsed data from Karafka to Sidekiq, to make it a default. In case you
18
+ # need this, please implement your own interchanger.
18
19
  def load(params_batch)
19
- params_batch
20
+ params_batch.parsed
20
21
  end
21
22
 
22
23
  # @param params_batch [Hash] Sidekiqs params that are now a Hash (after they were JSON#parse)
23
24
  # @note Since Sidekiq does not like symbols, we restore symbolized keys for system keys, so
24
25
  # everything can work as expected. Keep in mind, that custom data will always be assigned
25
- # with string keys per design. To change it, pleasae change this interchanger and create
26
+ # with string keys per design. To change it, please change this interchanger and create
26
27
  # your own custom parser
27
28
  def parse(params_batch)
28
29
  params_batch.map! do |params|
29
30
  Karafka::Params::Params::SYSTEM_KEYS.each do |key|
30
31
  stringified_key = key.to_s
31
- params[key] = params.delete(stringified_key) if params.key?(stringified_key)
32
+ next unless params.key?(stringified_key)
33
+ params[key] ||= params.delete(stringified_key)
32
34
  end
33
35
 
34
36
  params
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-sidekiq-backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta1
4
+ version: 1.2.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0.beta1
19
+ version: 1.2.0.beta2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0.beta1
26
+ version: 1.2.0.beta2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement