karafka-sidekiq-backend 1.0.0.pre1 → 1.0.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 +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +30 -2
- data/karafka-sidekiq-backend.gemspec +1 -1
- data/lib/karafka/backends/sidekiq.rb +2 -1
- data/lib/karafka/extensions/sidekiq_attributes_map.rb +7 -0
- data/lib/karafka/extensions/sidekiq_topic_attributes.rb +7 -0
- data/lib/karafka/interchanger.rb +7 -7
- data/lib/karafka-sidekiq-backend.rb +5 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac35518405825e475629928acad62fb4c971148b
|
4
|
+
data.tar.gz: 03db71a6d95e1f7eda063311c84b5f9383290f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a55f875872e7988bff3b4d97ad5828bb8e1766d1329cdaaad2312e08005d7bc1f55065d5a37cc0fd8f0dbc46d19a6ac1743067f1e9ed1d11264624003e1a345
|
7
|
+
data.tar.gz: a912aa6c87ef62998f444f23e2c4970400806c9ddb91f530ce8845e0bc6d3c781b03e9eaa4898e4e5e32c43a47ef5b3b812bff3dba3551a0057f36d88460d0d7
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
karafka-sidekiq-backend (1.0.0
|
5
|
-
karafka (>= 1.0.0
|
4
|
+
karafka-sidekiq-backend (1.0.0)
|
5
|
+
karafka (>= 1.0.0)
|
6
6
|
sidekiq (>= 4.2)
|
7
7
|
|
8
8
|
GEM
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
i18n (0.8.6)
|
68
68
|
inflecto (0.0.2)
|
69
69
|
json (2.1.0)
|
70
|
-
karafka (1.0.0
|
70
|
+
karafka (1.0.0)
|
71
71
|
activesupport (>= 5.0)
|
72
72
|
celluloid
|
73
73
|
dry-configurable (~> 0.7)
|
@@ -80,7 +80,7 @@ GEM
|
|
80
80
|
thor (~> 0.19)
|
81
81
|
waterdrop (>= 0.4)
|
82
82
|
minitest (5.10.3)
|
83
|
-
multi_json (1.12.
|
83
|
+
multi_json (1.12.2)
|
84
84
|
null-logger (0.1.4)
|
85
85
|
rack (2.0.3)
|
86
86
|
rack-protection (2.0.0)
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Karafka Sidekiq Backend
|
2
2
|
|
3
3
|
[](https://travis-ci.org/karafka/karafka-sidekiq-backend)
|
4
|
+
[](https://gitter.im/karafka/karafka?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
5
|
|
5
|
-
Karafka Sidekiq Backend provides support for processing received Kafka messages inside of Sidekiq workers.
|
6
|
+
[Karafka Sidekiq Backend](https://github.com/karafka/karafka-sidekiq-backend) provides support for processing received Kafka messages inside of Sidekiq workers.
|
6
7
|
|
7
8
|
## Installations
|
8
9
|
|
@@ -21,7 +22,7 @@ end
|
|
21
22
|
|
22
23
|
and you are ready to go. Karafka Sidekiq Backend integrates with Karafka automatically
|
23
24
|
|
24
|
-
Note
|
25
|
+
**Note**: You can name your application worker base class with any name you want. The only thing that is required is a direct inheritance from the ```Karafka::BaseWorker``` class.
|
25
26
|
|
26
27
|
## Usage
|
27
28
|
|
@@ -112,3 +113,30 @@ topic :binary_video_details do
|
|
112
113
|
interchanger Base64Interchanger
|
113
114
|
end
|
114
115
|
```
|
116
|
+
|
117
|
+
## References
|
118
|
+
|
119
|
+
* [Karafka framework](https://github.com/karafka/karafka)
|
120
|
+
* [Karafka Sidekiq Backend Travis CI](https://travis-ci.org/karafka/karafka-sidekiq-backend)
|
121
|
+
* [Karafka Sidekiq Backend Coditsu](https://app.coditsu.io/karafka/repositories/karafka-sidekiq-backend)
|
122
|
+
|
123
|
+
## Note on Patches/Pull Requests
|
124
|
+
|
125
|
+
Fork the project.
|
126
|
+
Make your feature addition or bug fix.
|
127
|
+
Add tests for it. This is important so we don't break it in a future versions unintentionally.
|
128
|
+
Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull). Send me a pull request. Bonus points for topic branches.
|
129
|
+
|
130
|
+
[](https://app.coditsu.io/karafka/repositories/karafka-sidekiq-backend)
|
131
|
+
|
132
|
+
Each pull request must pass our quality requirements. To check if everything is as it should be, we use [Coditsu](https://coditsu.io) that combinse multiple linters and code analyzers for both code and documentation.
|
133
|
+
|
134
|
+
Unfortunately, it does not yet support independent forks, however you should be fine by looking at what we require.
|
135
|
+
|
136
|
+
Please run:
|
137
|
+
|
138
|
+
```bash
|
139
|
+
bundle exec rake
|
140
|
+
```
|
141
|
+
|
142
|
+
to check if everything is in order. After that you can submit a pull request.
|
@@ -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.0.0
|
18
|
+
spec.add_dependency 'karafka', '>= 1.0.0'
|
19
19
|
spec.add_dependency 'sidekiq', '>= 4.2'
|
20
20
|
spec.required_ruby_version = '>= 2.3.0'
|
21
21
|
|
@@ -2,13 +2,20 @@
|
|
2
2
|
|
3
3
|
module Karafka
|
4
4
|
module Extensions
|
5
|
+
# Additional Karafka::Attributes map topic attributes that can be used when worker
|
6
|
+
# is active and we use sidekiq backend
|
5
7
|
module SidekiqAttributesMap
|
8
|
+
# Class methods that extend the attributes map class
|
6
9
|
module ClassMethods
|
10
|
+
# Extra topic fields that we need to have to work with sidekiq backend
|
11
|
+
# @return [Array<Symbol>] available topic options
|
7
12
|
def topic
|
8
13
|
super + %i[interchanger worker]
|
9
14
|
end
|
10
15
|
end
|
11
16
|
|
17
|
+
# Prepends class methods into attributes map
|
18
|
+
# @param base [Class] class that we prepend to
|
12
19
|
def self.prepended(base)
|
13
20
|
class << base
|
14
21
|
prepend ClassMethods
|
@@ -1,5 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Karafka
|
4
|
+
# Namespace for additional extensions that we include into some Karafka components, to gain
|
5
|
+
# extra features that we require
|
2
6
|
module Extensions
|
7
|
+
# Additional Karafka::Routing::Topic methods that are required to work with Sidekiq backend
|
3
8
|
module SidekiqTopicAttributes
|
4
9
|
# @return [Class] Class (not an instance) of a worker that should be used to schedule the
|
5
10
|
# background job
|
@@ -14,6 +19,8 @@ module Karafka
|
|
14
19
|
@interchanger ||= Karafka::Interchanger
|
15
20
|
end
|
16
21
|
|
22
|
+
# Creates attributes writers for worker and interchanger, so they can be overwritten
|
23
|
+
# @param base [Class] Karafka::Routing::Topic class
|
17
24
|
def self.included(base)
|
18
25
|
base.send :attr_writer, :worker
|
19
26
|
base.send :attr_writer, :interchanger
|
data/lib/karafka/interchanger.rb
CHANGED
@@ -9,24 +9,24 @@ module Karafka
|
|
9
9
|
# - parse - decoded params back to a hash format that we can use
|
10
10
|
class Interchanger
|
11
11
|
class << self
|
12
|
-
# @param
|
12
|
+
# @param params_batch [Karafka::Params::ParamsBatch] Karafka params batch object
|
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::
|
16
|
+
# @return [Karafka::Params::ParamsBatch] same as input. We assume that our incoming data is
|
17
17
|
# jsonable-safe and we can rely on a direct Sidekiq encoding logic
|
18
|
-
def load(
|
19
|
-
|
18
|
+
def load(params_batch)
|
19
|
+
params_batch
|
20
20
|
end
|
21
21
|
|
22
|
-
# @param
|
22
|
+
# @param params_batch [Hash] Sidekiqs params that are now a Hash (after they were JSON#parse)
|
23
23
|
# @note Hash is what we need to build Karafka::Params::Params, so we do nothing
|
24
24
|
# with it. If you implement your own interchanger logic, this method needs to return
|
25
25
|
# a hash with appropriate data that will be used to build Karafka::Params::Params
|
26
26
|
# @return [Hash] We return exactly what we received. We rely on sidekiqs default
|
27
27
|
# interchanging format
|
28
|
-
def parse(
|
29
|
-
|
28
|
+
def parse(params_batch)
|
29
|
+
params_batch
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
%w[
|
4
|
+
karafka
|
4
5
|
sidekiq
|
5
6
|
].each(&method(:require))
|
6
7
|
|
8
|
+
# Karafka framework namespace
|
7
9
|
module Karafka
|
10
|
+
# Namespace for all the backends that process data
|
8
11
|
module Backends
|
12
|
+
# Sidekiq Karafka backend
|
9
13
|
module Sidekiq
|
10
14
|
class << self
|
11
15
|
# @return [String] path to Karafka gem root core
|
@@ -17,4 +21,5 @@ module Karafka
|
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
24
|
+
# Uses Karafka loader to load all the sources that this backend needs
|
20
25
|
Karafka::Loader.load!(Karafka::Backends::Sidekiq.core_root)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karafka-sidekiq-backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: karafka
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0
|
19
|
+
version: 1.0.0
|
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.0.0
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,9 +81,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: 2.3.0
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: '0'
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
89
|
rubygems_version: 2.6.13
|