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 +4 -4
- data/CHANGELOG.md +2 -1
- data/Gemfile.lock +3 -3
- data/README.md +8 -4
- data/karafka-sidekiq-backend.gemspec +1 -1
- data/lib/karafka/backends/sidekiq.rb +3 -5
- data/lib/karafka/interchanger.rb +7 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cbf46f4edac28d13fad77fc120bf92456e37380bcee52718713ad94f4e9a5f2
|
4
|
+
data.tar.gz: 5da6e57d3f61b3d2f59410e78c7c94a1a26b04051714f2895f36ce00c2099e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c98cfa129b4733d21fa6fc0491ba522c89c5187fc1d1113b8256e9a980f50dba131353b61e37ee3f9867d8ad6e6a665abb0d2980ec3cff9bcab91fc3dfa9b53f
|
7
|
+
data.tar.gz: 63fd8534461a01e418e365f13ad207cfad9d5f7dff24adc09b8b15301e22749b3ad2d49b38ead45a70628722af90d2e36f5d48f3ce1cdadf1783567a9304fc93
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
karafka-sidekiq-backend (1.2.0.
|
5
|
-
karafka (>= 1.2.0.
|
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.
|
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(
|
102
|
-
|
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(
|
106
|
-
|
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.
|
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.
|
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
|
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
|
18
|
+
topic.interchanger.load(params_batch)
|
20
19
|
)
|
21
|
-
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
data/lib/karafka/interchanger.rb
CHANGED
@@ -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]
|
17
|
-
#
|
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,
|
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
|
-
|
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.
|
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.
|
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.
|
26
|
+
version: 1.2.0.beta2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|