karafka-sidekiq-backend 1.2.0 → 1.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/.coditsu/ci.yml +3 -0
- data/.github/FUNDING.yml +1 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +37 -18
- data/CHANGELOG.md +9 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +84 -85
- data/README.md +39 -8
- data/certs/mensfeld.pem +25 -0
- data/karafka-sidekiq-backend.gemspec +7 -2
- data/lib/karafka-sidekiq-backend.rb +1 -32
- data/lib/karafka/backends/sidekiq.rb +4 -2
- data/lib/karafka/base_worker.rb +40 -6
- data/lib/karafka/extensions/metadata_builder.rb +21 -0
- data/lib/karafka/extensions/params_batch_builder.rb +21 -0
- data/lib/karafka/extensions/params_builder.rb +19 -0
- data/lib/karafka/extensions/sidekiq_attributes_map.rb +1 -0
- data/lib/karafka/extensions/sidekiq_topic_attributes.rb +1 -5
- data/lib/karafka/extensions/stdout_listener.rb +27 -0
- data/lib/karafka/interchanger.rb +11 -13
- data/lib/karafka/workers/builder.rb +2 -9
- data/lib/karafka_sidekiq_backend.rb +28 -0
- metadata +43 -11
- metadata.gz.sig +0 -0
- data/lib/karafka/instrumentation/listener.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5fc5bf5aa80d215a0fa572fbe6853e046b4c5e9d6e39c1aac7a5178614e45f4
|
4
|
+
data.tar.gz: 9fcbdb5dd8b193c48669656bcdad9b20b894cf982ae400f0a11de57610922373
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37405ff9a618e5f21fe0bc38488f6ee6beef120f148e73cba28c78b91409656ef72d7dc2d28f0cf265af025e1b63c368dc645c2f86dae713d73147a0ddcedf12
|
7
|
+
data.tar.gz: 406316953d9e34be8f173e72f4baf389b982c504019b9da557a853975ed14cfa49020146565d5de74672db62690cf1e5b44b18509b71e1b727e3c5049c88eac2
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/.coditsu/ci.yml
ADDED
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
open_collective: karafka
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/.travis.yml
CHANGED
@@ -1,18 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
services:
|
2
|
+
- docker
|
3
|
+
|
4
|
+
dist: trusty
|
5
|
+
cache: bundler
|
6
|
+
|
7
|
+
git:
|
8
|
+
depth: false
|
9
|
+
|
10
|
+
test: &test
|
11
|
+
stage: Test
|
12
|
+
language: ruby
|
13
|
+
before_install:
|
14
|
+
- gem install bundler
|
15
|
+
- gem update --system
|
16
|
+
script: bundle exec rspec
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
include:
|
20
|
+
- <<: *test
|
21
|
+
rvm: 2.6.3
|
22
|
+
- <<: *test
|
23
|
+
rvm: 2.5.5
|
24
|
+
- <<: *test
|
25
|
+
rvm: 2.4.6
|
26
|
+
|
27
|
+
- stage: coditsu
|
28
|
+
language: ruby
|
29
|
+
rvm: 2.6.3
|
30
|
+
before_install:
|
31
|
+
- gem update --system
|
32
|
+
- gem install bundler
|
33
|
+
script: \curl -sSL https://api.coditsu.io/run/ci | bash
|
34
|
+
|
35
|
+
stages:
|
36
|
+
- coditsu
|
37
|
+
- test
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Karafka Sidekiq Backend
|
2
2
|
|
3
|
+
## 1.3.0.rc1 (2019-07-31)
|
4
|
+
- Ruby 2.6.3 support
|
5
|
+
- Drop Ruby 2.3 support
|
6
|
+
- Sync with Karafka: metadata support
|
7
|
+
- Sync with Karafka #463 (Split parsers into serializers / deserializers)
|
8
|
+
- #26 - Make listeners as instances
|
9
|
+
- Zeitwerk integration
|
10
|
+
- drop jruby support
|
11
|
+
|
3
12
|
## 1.2.0
|
4
13
|
- ```#load``` and ```#parse``` are renamed to ```#encode``` and ```#decode``` in interchangers
|
5
14
|
- #274 - Rename controllers to consumers
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,136 +1,135 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
karafka-sidekiq-backend (1.
|
5
|
-
karafka (~> 1.
|
4
|
+
karafka-sidekiq-backend (1.3.0.rc1)
|
5
|
+
karafka (~> 1.3.0.rc1)
|
6
6
|
sidekiq (>= 4.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
concurrent-ruby (1.0.5)
|
17
|
-
connection_pool (2.2.1)
|
18
|
-
delivery_boy (0.2.4)
|
19
|
-
king_konf (~> 0.1.8)
|
20
|
-
ruby-kafka (~> 0.5.1)
|
11
|
+
concurrent-ruby (1.1.5)
|
12
|
+
connection_pool (2.2.2)
|
13
|
+
delivery_boy (0.2.8)
|
14
|
+
king_konf (~> 0.3)
|
15
|
+
ruby-kafka (~> 0.7.8)
|
21
16
|
diff-lcs (1.3)
|
22
|
-
|
23
|
-
|
17
|
+
digest-crc (0.4.1)
|
18
|
+
docile (1.3.2)
|
19
|
+
dry-configurable (0.8.3)
|
24
20
|
concurrent-ruby (~> 1.0)
|
25
|
-
|
21
|
+
dry-core (~> 0.4, >= 0.4.7)
|
22
|
+
dry-container (0.7.2)
|
26
23
|
concurrent-ruby (~> 1.0)
|
27
24
|
dry-configurable (~> 0.1, >= 0.1.3)
|
28
|
-
dry-core (0.4.
|
25
|
+
dry-core (0.4.8)
|
29
26
|
concurrent-ruby (~> 1.0)
|
30
|
-
dry-equalizer (0.2.
|
31
|
-
dry-events (0.
|
27
|
+
dry-equalizer (0.2.2)
|
28
|
+
dry-events (0.2.0)
|
32
29
|
concurrent-ruby (~> 1.0)
|
33
30
|
dry-core (~> 0.4)
|
34
31
|
dry-equalizer (~> 0.2)
|
35
|
-
dry-inflector (0.1.
|
36
|
-
dry-
|
37
|
-
|
32
|
+
dry-inflector (0.1.2)
|
33
|
+
dry-initializer (3.0.1)
|
34
|
+
dry-logic (1.0.2)
|
35
|
+
concurrent-ruby (~> 1.0)
|
38
36
|
dry-core (~> 0.2)
|
39
37
|
dry-equalizer (~> 0.2)
|
40
|
-
dry-monitor (0.1
|
38
|
+
dry-monitor (0.3.1)
|
41
39
|
dry-configurable (~> 0.5)
|
40
|
+
dry-core (~> 0.4)
|
42
41
|
dry-equalizer (~> 0.2)
|
43
42
|
dry-events (~> 0.1)
|
44
|
-
|
45
|
-
dry-types (0.12.2)
|
43
|
+
dry-schema (1.3.1)
|
46
44
|
concurrent-ruby (~> 1.0)
|
47
|
-
dry-configurable (~> 0.
|
48
|
-
dry-
|
49
|
-
dry-core (~> 0.2, >= 0.2.1)
|
45
|
+
dry-configurable (~> 0.8, >= 0.8.3)
|
46
|
+
dry-core (~> 0.4)
|
50
47
|
dry-equalizer (~> 0.2)
|
51
|
-
dry-
|
52
|
-
|
53
|
-
|
48
|
+
dry-initializer (~> 3.0)
|
49
|
+
dry-logic (~> 1.0)
|
50
|
+
dry-types (~> 1.0)
|
51
|
+
dry-types (1.1.1)
|
54
52
|
concurrent-ruby (~> 1.0)
|
55
|
-
dry-
|
56
|
-
dry-core (~> 0.
|
53
|
+
dry-container (~> 0.3)
|
54
|
+
dry-core (~> 0.4, >= 0.4.4)
|
55
|
+
dry-equalizer (~> 0.2, >= 0.2.2)
|
56
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
57
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
58
|
+
dry-validation (1.2.1)
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
dry-container (~> 0.7, >= 0.7.1)
|
61
|
+
dry-core (~> 0.4)
|
57
62
|
dry-equalizer (~> 0.2)
|
58
|
-
dry-
|
59
|
-
dry-
|
63
|
+
dry-initializer (~> 3.0)
|
64
|
+
dry-schema (~> 1.0, >= 1.3.1)
|
60
65
|
envlogic (1.1.0)
|
61
66
|
dry-inflector (~> 0.1)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
dry-
|
69
|
-
dry-inflector (~> 0.1.1)
|
70
|
-
dry-monitor (~> 0.1)
|
71
|
-
dry-validation (~> 0.11)
|
67
|
+
irb (1.0.0)
|
68
|
+
json (2.2.0)
|
69
|
+
karafka (1.3.0.rc1)
|
70
|
+
dry-configurable (~> 0.8)
|
71
|
+
dry-inflector (~> 0.1)
|
72
|
+
dry-monitor (~> 0.3)
|
73
|
+
dry-validation (~> 1.2)
|
72
74
|
envlogic (~> 1.0)
|
75
|
+
irb (~> 1.0)
|
73
76
|
multi_json (>= 1.12)
|
74
77
|
rake (>= 11.3)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
king_konf (0.
|
80
|
-
minitest (5.11.3)
|
78
|
+
ruby-kafka (>= 0.7.8)
|
79
|
+
thor (~> 0.20)
|
80
|
+
waterdrop (~> 1.3.0.rc1)
|
81
|
+
zeitwerk (~> 2.1)
|
82
|
+
king_konf (0.3.7)
|
81
83
|
multi_json (1.13.1)
|
82
|
-
|
83
|
-
rack (2.0.
|
84
|
-
rack-protection (2.0.1)
|
84
|
+
rack (2.0.7)
|
85
|
+
rack-protection (2.0.5)
|
85
86
|
rack
|
86
|
-
rake (12.3.
|
87
|
-
redis (4.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
rspec-
|
92
|
-
|
93
|
-
rspec-
|
94
|
-
rspec-
|
95
|
-
rspec-support (~> 3.7.0)
|
96
|
-
rspec-expectations (3.7.0)
|
87
|
+
rake (12.3.3)
|
88
|
+
redis (4.1.2)
|
89
|
+
rspec (3.8.0)
|
90
|
+
rspec-core (~> 3.8.0)
|
91
|
+
rspec-expectations (~> 3.8.0)
|
92
|
+
rspec-mocks (~> 3.8.0)
|
93
|
+
rspec-core (3.8.2)
|
94
|
+
rspec-support (~> 3.8.0)
|
95
|
+
rspec-expectations (3.8.4)
|
97
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
98
|
-
rspec-support (~> 3.
|
99
|
-
rspec-mocks (3.
|
97
|
+
rspec-support (~> 3.8.0)
|
98
|
+
rspec-mocks (3.8.1)
|
100
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
101
|
-
rspec-support (~> 3.
|
102
|
-
rspec-support (3.
|
103
|
-
ruby-kafka (0.
|
104
|
-
|
105
|
-
|
106
|
-
connection_pool (~> 2.2, >= 2.2.
|
100
|
+
rspec-support (~> 3.8.0)
|
101
|
+
rspec-support (3.8.2)
|
102
|
+
ruby-kafka (0.7.9)
|
103
|
+
digest-crc
|
104
|
+
sidekiq (5.2.7)
|
105
|
+
connection_pool (~> 2.2, >= 2.2.2)
|
106
|
+
rack (>= 1.5.0)
|
107
107
|
rack-protection (>= 1.5.0)
|
108
108
|
redis (>= 3.3.5, < 5)
|
109
|
-
simplecov (0.
|
109
|
+
simplecov (0.17.0)
|
110
110
|
docile (~> 1.1)
|
111
111
|
json (>= 1.8, < 3)
|
112
112
|
simplecov-html (~> 0.10.0)
|
113
113
|
simplecov-html (0.10.2)
|
114
|
-
thor (0.20.
|
115
|
-
|
116
|
-
timecop (0.9.1)
|
117
|
-
tzinfo (1.2.5)
|
118
|
-
thread_safe (~> 0.1)
|
119
|
-
waterdrop (1.2.0)
|
114
|
+
thor (0.20.3)
|
115
|
+
waterdrop (1.3.0.rc1)
|
120
116
|
delivery_boy (~> 0.2)
|
121
|
-
dry-configurable (~> 0.
|
122
|
-
dry-monitor (~> 0.
|
123
|
-
dry-validation (~>
|
124
|
-
|
117
|
+
dry-configurable (~> 0.8)
|
118
|
+
dry-monitor (~> 0.3)
|
119
|
+
dry-validation (~> 1.2)
|
120
|
+
ruby-kafka (>= 0.7.8)
|
121
|
+
zeitwerk (~> 2.1)
|
122
|
+
zeitwerk (2.1.9)
|
125
123
|
|
126
124
|
PLATFORMS
|
127
125
|
ruby
|
128
126
|
|
129
127
|
DEPENDENCIES
|
128
|
+
karafka (= 1.3.0.rc1)
|
130
129
|
karafka-sidekiq-backend!
|
131
130
|
rspec
|
132
131
|
simplecov
|
133
|
-
|
132
|
+
waterdrop (= 1.3.0.rc1)
|
134
133
|
|
135
134
|
BUNDLED WITH
|
136
|
-
|
135
|
+
2.0.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Karafka Sidekiq Backend
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/karafka/sidekiq-backend.
|
3
|
+
[![Build Status](https://travis-ci.org/karafka/sidekiq-backend.svg)](https://travis-ci.org/karafka/sidekiq-backend)
|
4
4
|
[![Join the chat at https://gitter.im/karafka/karafka](https://badges.gitter.im/karafka/karafka.svg)](https://gitter.im/karafka/karafka?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
5
|
|
6
6
|
[Karafka Sidekiq Backend](https://github.com/karafka/sidekiq-backend) provides support for consuming (processing) received Kafka messages inside of Sidekiq workers.
|
@@ -45,7 +45,7 @@ or on a per topic level:
|
|
45
45
|
App.routes.draw do
|
46
46
|
consumer_group :videos_consumer do
|
47
47
|
topic :binary_video_details do
|
48
|
-
|
48
|
+
consumer Videos::DetailsConsumer
|
49
49
|
worker Workers::DetailsWorker
|
50
50
|
interchanger Interchangers::MyCustomInterchanger
|
51
51
|
end
|
@@ -53,7 +53,7 @@ App.routes.draw do
|
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
56
|
-
You don't need to do anything beyond that. Karafka will know, that you want to run your
|
56
|
+
You don't need to do anything beyond that. Karafka will know, that you want to run your consumer's ```#consume``` method in a background job.
|
57
57
|
|
58
58
|
## Configuration
|
59
59
|
|
@@ -67,7 +67,7 @@ There are two options you can set inside of the ```topic``` block:
|
|
67
67
|
|
68
68
|
### Workers
|
69
69
|
|
70
|
-
Karafka by default will build a worker that will correspond to each of your
|
70
|
+
Karafka by default will build a worker that will correspond to each of your consumers (so you will have a pair - consumer and a worker). All of them will inherit from ```ApplicationWorker``` and will share all its settings.
|
71
71
|
|
72
72
|
To run Sidekiq you should have sidekiq.yml file in *config* folder. The example of ```sidekiq.yml``` file will be generated to config/sidekiq.yml.example once you run ```bundle exec karafka install```.
|
73
73
|
|
@@ -75,17 +75,17 @@ However, if you want to use a raw Sidekiq worker (without any Karafka additional
|
|
75
75
|
|
76
76
|
```ruby
|
77
77
|
topic :incoming_messages do
|
78
|
-
|
78
|
+
consumer MessagesConsumer
|
79
79
|
worker MyCustomWorker
|
80
80
|
end
|
81
81
|
```
|
82
82
|
|
83
|
-
Note that even then, you need to specify a
|
83
|
+
Note that even then, you need to specify a consumer that will schedule a background task.
|
84
84
|
|
85
85
|
Custom workers need to provide a ```#perform_async``` method. It needs to accept two arguments:
|
86
86
|
|
87
87
|
- ```topic_id``` - first argument is a current topic id from which a given message comes
|
88
|
-
- ```params_batch``` - all the params that came from Kafka + additional metadata. This data format might be changed if you use custom interchangers. Otherwise it will be an instance of Karafka::Params::ParamsBatch.
|
88
|
+
- ```params_batch``` - all the params that came from Kafka + additional metadata. This data format might be changed if you use custom interchangers. Otherwise, it will be an instance of Karafka::Params::ParamsBatch.
|
89
89
|
|
90
90
|
**Note**: If you use custom interchangers, keep in mind, that params inside params batch might be in two states: parsed or unparsed when passed to #perform_async. This means, that if you use custom interchangers and/or custom workers, you might want to look into Karafka's sources to see exactly how it works.
|
91
91
|
|
@@ -93,6 +93,37 @@ Custom workers need to provide a ```#perform_async``` method. It needs to accept
|
|
93
93
|
|
94
94
|
Custom interchangers target issues with non-standard (binary, etc.) data that we want to store when we do ```#perform_async```. This data might be corrupted when fetched in a worker (see [this](https://github.com/karafka/karafka/issues/30) issue). With custom interchangers, you can encode/compress data before it is being passed to scheduling and decode/decompress it when it gets into the worker.
|
95
95
|
|
96
|
+
To specify the interchanger for a topic, specify the interchanger inside routes like this:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
App.routes.draw do
|
100
|
+
consumer_group :videos_consumer do
|
101
|
+
topic :binary_video_details do
|
102
|
+
consumer Videos::DetailsConsumer
|
103
|
+
interchanger Interchangers::MyCustomInterchanger
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
```
|
108
|
+
Each custom interchanger should define `encode` to encode params before they get stored in Redis, and `decode` to convert the params to hash format, as shown below:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
class Base64Interchanger
|
112
|
+
class << self
|
113
|
+
def encode(params_batch)
|
114
|
+
# Note, that you need to cast the params_batch to an array in order to get it work
|
115
|
+
# in sidekiq later
|
116
|
+
Base64.encode64(Marshal.dump(params_batch.to_a))
|
117
|
+
end
|
118
|
+
|
119
|
+
def decode(params_string)
|
120
|
+
Marshal.load(Base64.decode64(params_string))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
```
|
126
|
+
|
96
127
|
**Warning**: if you decide to use slow interchangers, they might significantly slow down Karafka.
|
97
128
|
|
98
129
|
## References
|
@@ -105,7 +136,7 @@ Custom interchangers target issues with non-standard (binary, etc.) data that we
|
|
105
136
|
|
106
137
|
First, thank you for considering contributing to Karafka! It's people like you that make the open source community such a great community!
|
107
138
|
|
108
|
-
Each pull request must pass all the
|
139
|
+
Each pull request must pass all the RSpec specs and meet our quality requirements.
|
109
140
|
|
110
141
|
To check if everything is as it should be, we use [Coditsu](https://coditsu.io) that combines multiple linters and code analyzers for both code and documentation. Once you're done with your changes, submit a pull request.
|
111
142
|
|
data/certs/mensfeld.pem
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhtYWNp
|
3
|
+
ZWovREM9bWVuc2ZlbGQvREM9cGwwHhcNMTkwNzMwMTQ1NDU0WhcNMjAwNzI5MTQ1
|
4
|
+
NDU0WjAjMSEwHwYDVQQDDBhtYWNpZWovREM9bWVuc2ZlbGQvREM9cGwwggGiMA0G
|
5
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC9fCwtaHZG2SyyNXiH8r0QbJQx/xxl
|
6
|
+
dkvwWz9QGJO+O8rEx20FB1Ab+MVkfOscwIv5jWpmk1U9whzDPl1uFtIbgu+sk+Zb
|
7
|
+
uQlZyK/DPN6c+/BbBL+RryTBRyvkPLoCVwm7uxc/JZ1n4AI6eF4cCZ2ieZ9QgQbU
|
8
|
+
MQs2QPqs9hT50Ez/40GnOdadVfiDDGz+NME2C4ms0BriXwZ1tcRTfJIHe2xjIbbb
|
9
|
+
y5qRGfsLKcgMzvLQR24olixyX1MR0s4+Wveq3QL/gBhL4veUcv+UABJA8IJR0kyB
|
10
|
+
seHHutusiwZ1v3SjjjW1xLLrc2ARV0mgCb0WaK2T4iA3oFTGLh6Ydz8LNl31KQFv
|
11
|
+
94nRd8IhmJxrhQ6dQ/WT9IXoa5S9lfT5lPJeINemH4/6QPABzf9W2IZlCdI9wCdB
|
12
|
+
TBaw57MKneGAYZiKjw6OALSy2ltQUCl3RqFl3VP7n8uFy1U987Q5VIIQ3O1UUsQD
|
13
|
+
Oe/h+r7GUU4RSPKgPlrwvW9bD/UQ+zF51v8CAwEAAaN3MHUwCQYDVR0TBAIwADAL
|
14
|
+
BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFJNIBHdfEUD7TqHqIer2YhWaWhwcMB0GA1Ud
|
15
|
+
EQQWMBSBEm1hY2llakBtZW5zZmVsZC5wbDAdBgNVHRIEFjAUgRJtYWNpZWpAbWVu
|
16
|
+
c2ZlbGQucGwwDQYJKoZIhvcNAQELBQADggGBAKA4eqko6BTNhlysip6rfBkVTGri
|
17
|
+
ZXsL+kRb2hLvsQJS/kLyM21oMlu+LN0aPj3qEFR8mE/YeDD8rLAfruBRTltPNbR7
|
18
|
+
xA5eE1gkxY5LfExUtK3b2wPqfmo7mZgfcsMwfYg/tUXw1WpBCnrhAJodpGH6SXmp
|
19
|
+
A40qFUZst0vjiOoO+aTblIHPmMJXoZ3K42dTlNKlEiDKUWMRKSgpjjYGEYalFNWI
|
20
|
+
hHfCz2r8L2t+dYdMZg1JGbEkq4ADGsAA8ioZIpJd7V4hI17u5TCdi7X5wh/0gN0E
|
21
|
+
CgP+nLox3D+l2q0QuQEkayr+auFYkzTCkF+BmEk1D0Ru4mcf3F4CJvEmW4Pzbjqt
|
22
|
+
i1tsCWPtJ4E/UUKnKaWKqGbjrjHJ0MuShYzHkodox5IOiCXIQg+1+YSzfXUV6WEK
|
23
|
+
KJG/fhg1JV5vVDdVy6x+tv5SQ5ctU0feCsVfESi3rE3zRd+nvzE9HcZ5aXeL1UtJ
|
24
|
+
nT5Xrioegu2w1jPyVEgyZgTZC5rvD0nNS5sFNQ==
|
25
|
+
-----END CERTIFICATE-----
|
@@ -15,10 +15,15 @@ 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.
|
18
|
+
spec.add_dependency 'karafka', '~> 1.3.0.rc1'
|
19
19
|
spec.add_dependency 'sidekiq', '>= 4.2'
|
20
|
-
spec.required_ruby_version = '>= 2.
|
20
|
+
spec.required_ruby_version = '>= 2.4.0'
|
21
21
|
|
22
|
+
if $PROGRAM_NAME.end_with?('gem')
|
23
|
+
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.cert_chain = %w[certs/mensfeld.pem]
|
22
27
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
23
28
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
29
|
spec.require_paths = %w[lib]
|
@@ -1,34 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# to require it again in the gemspec, etc
|
5
|
-
%w[
|
6
|
-
karafka
|
7
|
-
sidekiq
|
8
|
-
active_support/core_ext/class/subclasses
|
9
|
-
].each(&method(:require))
|
10
|
-
|
11
|
-
# Karafka framework namespace
|
12
|
-
module Karafka
|
13
|
-
# Namespace for all the backends that process data
|
14
|
-
module Backends
|
15
|
-
# Sidekiq Karafka backend
|
16
|
-
module Sidekiq
|
17
|
-
class << self
|
18
|
-
# @return [String] path to Karafka gem root core
|
19
|
-
def core_root
|
20
|
-
Pathname.new(File.expand_path('karafka', __dir__))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Uses Karafka loader to load all the sources that this backend needs
|
28
|
-
Karafka::Loader.load!(Karafka::Backends::Sidekiq.core_root)
|
29
|
-
Karafka::AttributesMap.prepend(Karafka::Extensions::SidekiqAttributesMap)
|
30
|
-
# Register internal events for instrumentation
|
31
|
-
%w[
|
32
|
-
backends.sidekiq.process
|
33
|
-
backends.sidekiq.base_worker.perform
|
34
|
-
].each(&Karafka.monitor.method(:register_event))
|
3
|
+
require 'karafka_sidekiq_backend'
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Karafka
|
4
|
+
# Namespace for alternative processing backends for Karafka framework
|
4
5
|
module Backends
|
5
6
|
# Sidekiq backend that schedules stuff to Sidekiq worker for delayed execution
|
6
7
|
module Sidekiq
|
7
8
|
# Karafka Sidekiq backend version
|
8
|
-
VERSION = '1.
|
9
|
+
VERSION = '1.3.0.rc1'
|
9
10
|
|
10
11
|
# Enqueues the execution of perform method into a worker.
|
11
12
|
# @note Each worker needs to have a class #perform_async method that will allow us to pass
|
@@ -16,7 +17,8 @@ module Karafka
|
|
16
17
|
Karafka.monitor.instrument('backends.sidekiq.process', caller: self) do
|
17
18
|
topic.worker.perform_async(
|
18
19
|
topic.id,
|
19
|
-
topic.interchanger.encode(params_batch)
|
20
|
+
topic.interchanger.encode(params_batch),
|
21
|
+
respond_to?(:metadata) ? metadata : nil
|
20
22
|
)
|
21
23
|
end
|
22
24
|
end
|
data/lib/karafka/base_worker.rb
CHANGED
@@ -5,11 +5,30 @@ module Karafka
|
|
5
5
|
class BaseWorker
|
6
6
|
include Sidekiq::Worker
|
7
7
|
|
8
|
+
class << self
|
9
|
+
# Returns the base worker class for application.
|
10
|
+
#
|
11
|
+
# @return [Class] first worker that inherited from Karafka::BaseWorker. Karafka
|
12
|
+
# assumes that it is the base worker for an application.
|
13
|
+
# @raise [Karafka::Errors::BaseWorkerDescentantMissing] raised when application
|
14
|
+
# base worker was not defined.
|
15
|
+
def base_worker
|
16
|
+
@inherited || raise(Errors::BaseWorkerDescentantMissing)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param subclass [Class] subclass of the worker
|
20
|
+
# @return [Class] subclass of the worker that was selected
|
21
|
+
def inherited(subclass)
|
22
|
+
@inherited ||= subclass
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
8
26
|
# Executes the logic that lies in #perform Karafka consumer method
|
9
27
|
# @param topic_id [String] Unique topic id that we will use to find a proper topic
|
10
|
-
# @param params_batch [Array] Array with messages batch
|
11
|
-
|
12
|
-
|
28
|
+
# @param params_batch [Array<Hash>] Array with messages batch
|
29
|
+
# @param metadata [Hash, nil] hash with all the metadata or nil if not present
|
30
|
+
def perform(topic_id, params_batch, metadata)
|
31
|
+
consumer = consumer(topic_id, params_batch, metadata)
|
13
32
|
|
14
33
|
Karafka.monitor.instrument(
|
15
34
|
'backends.sidekiq.base_worker.perform',
|
@@ -20,12 +39,27 @@ module Karafka
|
|
20
39
|
|
21
40
|
private
|
22
41
|
|
42
|
+
# @see `#perform` for exact params descriptions
|
43
|
+
# @param topic_id [String]
|
44
|
+
# @param params_batch [Array<Hash>]
|
45
|
+
# @param metadata [Hash, nil]
|
23
46
|
# @return [Karafka::Consumer] descendant of Karafka::BaseConsumer that matches the topic
|
24
47
|
# with params_batch assigned already (consumer is ready to use)
|
25
|
-
def consumer(topic_id, params_batch)
|
48
|
+
def consumer(topic_id, params_batch, metadata)
|
26
49
|
topic = Karafka::Routing::Router.find(topic_id)
|
27
|
-
consumer = topic.consumer.new
|
28
|
-
consumer.params_batch =
|
50
|
+
consumer = topic.consumer.new(topic)
|
51
|
+
consumer.params_batch = Params::Builders::ParamsBatch.from_array(
|
52
|
+
topic.interchanger.decode(params_batch),
|
53
|
+
topic
|
54
|
+
)
|
55
|
+
|
56
|
+
if topic.batch_fetching
|
57
|
+
consumer.metadata = Params::Builders::Metadata.from_hash(
|
58
|
+
metadata,
|
59
|
+
topic
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
29
63
|
consumer
|
30
64
|
end
|
31
65
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
module Extensions
|
5
|
+
# Extension for metadata builder to allow building metadata from a hash
|
6
|
+
module MetadataBuilder
|
7
|
+
# Builds metadata from hash
|
8
|
+
# @param hash [Hash] hash with metadata
|
9
|
+
# @param topic [Karafka::Routing::Topic] topic instance
|
10
|
+
# @return [Karafka::Params::Metadata] metadata instance
|
11
|
+
def from_hash(hash, topic)
|
12
|
+
# Parser needs to be merged as this is the only non-serializable object
|
13
|
+
# so it gets reconstructed from the topic
|
14
|
+
Karafka::Params::Metadata
|
15
|
+
.new
|
16
|
+
.merge!(hash)
|
17
|
+
.merge!('deserializer' => topic.deserializer)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
module Extensions
|
5
|
+
# Extension for params batch builder for reconstruction of the batch from an array
|
6
|
+
module ParamsBatchBuilder
|
7
|
+
# Builds params batch from array of hashes
|
8
|
+
# @param array [Array<Hash>] array with hash messages
|
9
|
+
# @param topic [Karafka::Routing::Topic] topic for which we build the batch
|
10
|
+
# @return [Karafka::Params::ParamsBatch] built batch
|
11
|
+
# @note We rebuild the params batch from array after the serialization
|
12
|
+
def from_array(array, topic)
|
13
|
+
params_array = array.map! do |hash|
|
14
|
+
Karafka::Params::Builders::Params.from_hash(hash, topic)
|
15
|
+
end
|
16
|
+
|
17
|
+
Karafka::Params::ParamsBatch.new(params_array)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
module Extensions
|
5
|
+
# Extension for rebuilding params from a hash
|
6
|
+
module ParamsBuilder
|
7
|
+
# Builds params from a hash
|
8
|
+
# @param hash [Hash] hash with params details
|
9
|
+
# @param topic [Karafka::Routing::Topic] topic for which we build the params
|
10
|
+
# @return [Karafka::Params::Params] built params
|
11
|
+
def from_hash(hash, topic)
|
12
|
+
Karafka::Params::Params
|
13
|
+
.new
|
14
|
+
.merge!(hash)
|
15
|
+
.merge!('deserializer' => topic.deserializer)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Karafka
|
4
|
-
# Namespace for additional extensions that we include into some Karafka components, to gain
|
5
|
-
# extra features that we require
|
6
4
|
module Extensions
|
7
5
|
# Additional Karafka::Routing::Topic methods that are required to work with Sidekiq backend
|
8
6
|
module SidekiqTopicAttributes
|
@@ -16,7 +14,7 @@ module Karafka
|
|
16
14
|
# @return [Class] Interchanger class (not an instance) that we want to use to interchange
|
17
15
|
# params between Karafka server and Karafka background job
|
18
16
|
def interchanger
|
19
|
-
@interchanger ||= Karafka::Interchanger
|
17
|
+
@interchanger ||= Karafka::Interchanger.new
|
20
18
|
end
|
21
19
|
|
22
20
|
# Creates attributes writers for worker and interchanger, so they can be overwritten
|
@@ -28,5 +26,3 @@ module Karafka
|
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
31
|
-
|
32
|
-
Karafka::Routing::Topic.include Karafka::Extensions::SidekiqTopicAttributes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Karafka
|
4
|
+
module Extensions
|
5
|
+
# Additional methods for listener that listen on instrumentation related to the Sidekiq
|
6
|
+
# backend of Karafka
|
7
|
+
module StdoutListener
|
8
|
+
# Logs info about scheduling of a certain dataset with a Sidekiq backend
|
9
|
+
# @param event [Dry::Events::Event] event details including payload
|
10
|
+
def on_backends_sidekiq_process(event)
|
11
|
+
count = event[:caller].send(:params_batch).to_a.size
|
12
|
+
topic = event[:caller].topic.name
|
13
|
+
time = event[:time]
|
14
|
+
info "Scheduling of #{count} messages to Sidekiq on topic #{topic} took #{time} ms"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Logs ino about processing certain events with a given Sidekiq worker
|
18
|
+
# @param event [Dry::Events::Event] event details including payload
|
19
|
+
def on_backends_sidekiq_base_worker_perform(event)
|
20
|
+
count = event[:consumer].send(:params_batch).to_a.size
|
21
|
+
topic = event[:consumer].topic.name
|
22
|
+
time = event[:time]
|
23
|
+
info "Sidekiq processing of topic #{topic} with #{count} messages took #{time} ms"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/karafka/interchanger.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Karafka
|
4
|
-
#
|
4
|
+
# Interchanger allows us to format/encode/pack data that is being send to perform_async
|
5
5
|
# This is meant to target mostly issues with data encoding like this one:
|
6
6
|
# https://github.com/mperham/sidekiq/issues/197
|
7
7
|
# Each custom interchanger should implement following methods:
|
@@ -10,19 +10,17 @@ module Karafka
|
|
10
10
|
#
|
11
11
|
# This interchanger uses default Sidekiq options to exchange data
|
12
12
|
class Interchanger
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
13
|
+
# @param params_batch [Karafka::Params::ParamsBatch] Karafka params batch object
|
14
|
+
# @return [Array<Karafka::Params::Params>] Array with hash/hashwithindiff values that will
|
15
|
+
# be serialized using Sidekiq serialization engine
|
16
|
+
def encode(params_batch)
|
17
|
+
params_batch.to_a
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
20
|
+
# @param params_batch [Array<Hash>] Sidekiq params that are now an array
|
21
|
+
# @return [Array<Hash>] exactly what we've fetched from Sidekiq
|
22
|
+
def decode(params_batch)
|
23
|
+
params_batch
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
@@ -23,20 +23,13 @@ module Karafka
|
|
23
23
|
# build #=> Videos::NewVideosWorker
|
24
24
|
def build
|
25
25
|
return matcher.match if matcher.match
|
26
|
-
|
26
|
+
|
27
|
+
klass = Class.new(Karafka::BaseWorker.base_worker)
|
27
28
|
matcher.scope.const_set(matcher.name, klass)
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
31
32
|
|
32
|
-
# @return [Class] descendant of Karafka::BaseWorker from which all other workers
|
33
|
-
# should inherit
|
34
|
-
# @raise [Karafka::Errors::BaseWorkerDescentantMissing] raised when Karafka cannot detect
|
35
|
-
# direct Karafka::BaseWorker descendant from which it could build workers
|
36
|
-
def base
|
37
|
-
Karafka::BaseWorker.subclasses.first || raise(Errors::BaseWorkerDescentantMissing)
|
38
|
-
end
|
39
|
-
|
40
33
|
# @return [Karafka::Helpers::ClassMatcher] matcher instance for matching between consumer
|
41
34
|
# and appropriate worker
|
42
35
|
def matcher
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
%w[
|
4
|
+
karafka
|
5
|
+
sidekiq
|
6
|
+
].each(&method(:require))
|
7
|
+
|
8
|
+
require_relative 'karafka/errors'
|
9
|
+
|
10
|
+
Zeitwerk::Loader
|
11
|
+
.for_gem
|
12
|
+
.tap { |loader| loader.ignore("#{__dir__}/karafka_sidekiq_backend.rb") }
|
13
|
+
.tap { |loader| loader.ignore("#{__dir__}/karafka-sidekiq-backend.rb") }
|
14
|
+
.tap(&:setup)
|
15
|
+
.tap(&:eager_load)
|
16
|
+
|
17
|
+
Karafka::Params::Builders::Params.extend(Karafka::Extensions::ParamsBuilder)
|
18
|
+
Karafka::Params::Builders::ParamsBatch.extend(Karafka::Extensions::ParamsBatchBuilder)
|
19
|
+
Karafka::Params::Builders::Metadata.extend(Karafka::Extensions::MetadataBuilder)
|
20
|
+
Karafka::Routing::Topic.include(Karafka::Extensions::SidekiqTopicAttributes)
|
21
|
+
Karafka::AttributesMap.prepend(Karafka::Extensions::SidekiqAttributesMap)
|
22
|
+
Karafka::Instrumentation::StdoutListener.include(Karafka::Extensions::StdoutListener)
|
23
|
+
|
24
|
+
# Register internal events for instrumentation
|
25
|
+
%w[
|
26
|
+
backends.sidekiq.process
|
27
|
+
backends.sidekiq.base_worker.perform
|
28
|
+
].each(&Karafka.monitor.method(:register_event))
|
metadata
CHANGED
@@ -1,14 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karafka-sidekiq-backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEODCCAqCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhtYWNp
|
14
|
+
ZWovREM9bWVuc2ZlbGQvREM9cGwwHhcNMTkwNzMwMTQ1NDU0WhcNMjAwNzI5MTQ1
|
15
|
+
NDU0WjAjMSEwHwYDVQQDDBhtYWNpZWovREM9bWVuc2ZlbGQvREM9cGwwggGiMA0G
|
16
|
+
CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC9fCwtaHZG2SyyNXiH8r0QbJQx/xxl
|
17
|
+
dkvwWz9QGJO+O8rEx20FB1Ab+MVkfOscwIv5jWpmk1U9whzDPl1uFtIbgu+sk+Zb
|
18
|
+
uQlZyK/DPN6c+/BbBL+RryTBRyvkPLoCVwm7uxc/JZ1n4AI6eF4cCZ2ieZ9QgQbU
|
19
|
+
MQs2QPqs9hT50Ez/40GnOdadVfiDDGz+NME2C4ms0BriXwZ1tcRTfJIHe2xjIbbb
|
20
|
+
y5qRGfsLKcgMzvLQR24olixyX1MR0s4+Wveq3QL/gBhL4veUcv+UABJA8IJR0kyB
|
21
|
+
seHHutusiwZ1v3SjjjW1xLLrc2ARV0mgCb0WaK2T4iA3oFTGLh6Ydz8LNl31KQFv
|
22
|
+
94nRd8IhmJxrhQ6dQ/WT9IXoa5S9lfT5lPJeINemH4/6QPABzf9W2IZlCdI9wCdB
|
23
|
+
TBaw57MKneGAYZiKjw6OALSy2ltQUCl3RqFl3VP7n8uFy1U987Q5VIIQ3O1UUsQD
|
24
|
+
Oe/h+r7GUU4RSPKgPlrwvW9bD/UQ+zF51v8CAwEAAaN3MHUwCQYDVR0TBAIwADAL
|
25
|
+
BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFJNIBHdfEUD7TqHqIer2YhWaWhwcMB0GA1Ud
|
26
|
+
EQQWMBSBEm1hY2llakBtZW5zZmVsZC5wbDAdBgNVHRIEFjAUgRJtYWNpZWpAbWVu
|
27
|
+
c2ZlbGQucGwwDQYJKoZIhvcNAQELBQADggGBAKA4eqko6BTNhlysip6rfBkVTGri
|
28
|
+
ZXsL+kRb2hLvsQJS/kLyM21oMlu+LN0aPj3qEFR8mE/YeDD8rLAfruBRTltPNbR7
|
29
|
+
xA5eE1gkxY5LfExUtK3b2wPqfmo7mZgfcsMwfYg/tUXw1WpBCnrhAJodpGH6SXmp
|
30
|
+
A40qFUZst0vjiOoO+aTblIHPmMJXoZ3K42dTlNKlEiDKUWMRKSgpjjYGEYalFNWI
|
31
|
+
hHfCz2r8L2t+dYdMZg1JGbEkq4ADGsAA8ioZIpJd7V4hI17u5TCdi7X5wh/0gN0E
|
32
|
+
CgP+nLox3D+l2q0QuQEkayr+auFYkzTCkF+BmEk1D0Ru4mcf3F4CJvEmW4Pzbjqt
|
33
|
+
i1tsCWPtJ4E/UUKnKaWKqGbjrjHJ0MuShYzHkodox5IOiCXIQg+1+YSzfXUV6WEK
|
34
|
+
KJG/fhg1JV5vVDdVy6x+tv5SQ5ctU0feCsVfESi3rE3zRd+nvzE9HcZ5aXeL1UtJ
|
35
|
+
nT5Xrioegu2w1jPyVEgyZgTZC5rvD0nNS5sFNQ==
|
36
|
+
-----END CERTIFICATE-----
|
37
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
38
|
dependencies:
|
13
39
|
- !ruby/object:Gem::Dependency
|
14
40
|
name: karafka
|
@@ -16,14 +42,14 @@ dependencies:
|
|
16
42
|
requirements:
|
17
43
|
- - "~>"
|
18
44
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
45
|
+
version: 1.3.0.rc1
|
20
46
|
type: :runtime
|
21
47
|
prerelease: false
|
22
48
|
version_requirements: !ruby/object:Gem::Requirement
|
23
49
|
requirements:
|
24
50
|
- - "~>"
|
25
51
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
52
|
+
version: 1.3.0.rc1
|
27
53
|
- !ruby/object:Gem::Dependency
|
28
54
|
name: sidekiq
|
29
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +71,8 @@ executables: []
|
|
45
71
|
extensions: []
|
46
72
|
extra_rdoc_files: []
|
47
73
|
files:
|
74
|
+
- ".coditsu/ci.yml"
|
75
|
+
- ".github/FUNDING.yml"
|
48
76
|
- ".gitignore"
|
49
77
|
- ".rspec"
|
50
78
|
- ".ruby-gemset"
|
@@ -56,17 +84,22 @@ files:
|
|
56
84
|
- MIT-LICENCE
|
57
85
|
- README.md
|
58
86
|
- Rakefile
|
87
|
+
- certs/mensfeld.pem
|
59
88
|
- karafka-sidekiq-backend.gemspec
|
60
89
|
- lib/karafka-sidekiq-backend.rb
|
61
90
|
- lib/karafka/backends/sidekiq.rb
|
62
91
|
- lib/karafka/base_worker.rb
|
63
92
|
- lib/karafka/cli/worker.rb
|
64
93
|
- lib/karafka/errors.rb
|
94
|
+
- lib/karafka/extensions/metadata_builder.rb
|
95
|
+
- lib/karafka/extensions/params_batch_builder.rb
|
96
|
+
- lib/karafka/extensions/params_builder.rb
|
65
97
|
- lib/karafka/extensions/sidekiq_attributes_map.rb
|
66
98
|
- lib/karafka/extensions/sidekiq_topic_attributes.rb
|
67
|
-
- lib/karafka/
|
99
|
+
- lib/karafka/extensions/stdout_listener.rb
|
68
100
|
- lib/karafka/interchanger.rb
|
69
101
|
- lib/karafka/workers/builder.rb
|
102
|
+
- lib/karafka_sidekiq_backend.rb
|
70
103
|
homepage: https://github.com/karafka/karafka-sidekiq-backend
|
71
104
|
licenses:
|
72
105
|
- MIT
|
@@ -79,15 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
112
|
requirements:
|
80
113
|
- - ">="
|
81
114
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
115
|
+
version: 2.4.0
|
83
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
117
|
requirements:
|
85
|
-
- - "
|
118
|
+
- - ">"
|
86
119
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
120
|
+
version: 1.3.1
|
88
121
|
requirements: []
|
89
|
-
|
90
|
-
rubygems_version: 2.7.6
|
122
|
+
rubygems_version: 3.0.3
|
91
123
|
signing_key:
|
92
124
|
specification_version: 4
|
93
125
|
summary: Karafka Sidekiq backend for background messages processing
|
metadata.gz.sig
ADDED
Binary file
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Karafka
|
4
|
-
# Namespace for extensions of Karafka core framework instrumentation
|
5
|
-
module Instrumentation
|
6
|
-
# Additional methods for listener that listen on instrumentation related to the Sidekiq
|
7
|
-
# backend of Karafka
|
8
|
-
module Listener
|
9
|
-
class << self
|
10
|
-
# Logs info about scheduling of a certain dataset with a Sidekiq backend
|
11
|
-
# @param event [Dry::Events::Event] event details including payload
|
12
|
-
def on_backends_sidekiq_process(event)
|
13
|
-
count = event[:caller].send(:params_batch).to_a.size
|
14
|
-
topic = event[:caller].topic.name
|
15
|
-
time = event[:time]
|
16
|
-
info "Scheduling of #{count} messages to Sidekiq on topic #{topic} took #{time} ms"
|
17
|
-
end
|
18
|
-
|
19
|
-
# Logs ino about processing certain events with a given Sidekiq worker
|
20
|
-
# @param event [Dry::Events::Event] event details including payload
|
21
|
-
def on_backends_sidekiq_base_worker_perform(event)
|
22
|
-
count = event[:consumer].send(:params_batch).to_a.size
|
23
|
-
topic = event[:consumer].topic.name
|
24
|
-
time = event[:time]
|
25
|
-
info "Sidekiq processing of topic #{topic} with #{count} messages took #{time} ms"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|