karafka-avro 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coditsu/ci.yml +3 -0
- data/.diffend.yml +3 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/ci.yml +71 -0
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +45 -0
- data/LICENSE +165 -0
- data/README.md +78 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/karafka-avro-parser.gemspec +30 -0
- data/lib/karafka-avro-parser.rb +3 -0
- data/lib/karafka/parsers/avro.rb +33 -0
- data/lib/karafka/parsers/avro/parser.rb +27 -0
- data/lib/karafka/parsers/avro/version.rb +9 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ba576321bfb1956e8bce5828444014e8c01c9906d77a28a86d68bce6133ee01b
|
4
|
+
data.tar.gz: 104572fc3df381456342d8710e0692b123223771b0ceb0bc18ca4fb5ba06ff3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a515d76a256189f8645abf52a110791fc6e7648c3af880a50924f7b7177a346882b31d76a6ab8ab81405e14cd8829ed11dde31b6abac86e5d7e245e2dde79a2a
|
7
|
+
data.tar.gz: f622c3bcf2b35c2f13da30efb539dc44a9d6ffab1aeb34b8911b48d53a98fd6bf8c6239b01e34ae42ff87c8756f44545d60b49c4cb4857d873697ee3d4c6fd16
|
data/.coditsu/ci.yml
ADDED
data/.diffend.yml
ADDED
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
open_collective: karafka
|
@@ -0,0 +1,71 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
schedule:
|
7
|
+
- cron: '0 1 * * *'
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
specs:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
needs: diffend
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- '3.0'
|
18
|
+
- '2.7'
|
19
|
+
- '2.6'
|
20
|
+
- '2.5'
|
21
|
+
include:
|
22
|
+
- ruby: '3.0'
|
23
|
+
coverage: 'true'
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Install package dependencies
|
27
|
+
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
|
28
|
+
- name: Set up Ruby
|
29
|
+
uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{matrix.ruby}}
|
32
|
+
- name: Install latest bundler
|
33
|
+
run: |
|
34
|
+
gem install bundler --no-document
|
35
|
+
- name: Bundle install
|
36
|
+
run: |
|
37
|
+
bundle install --jobs 4 --retry 3
|
38
|
+
- name: Run all tests
|
39
|
+
env:
|
40
|
+
GITHUB_COVERAGE: ${{matrix.coverage}}
|
41
|
+
run: bundle exec rspec
|
42
|
+
|
43
|
+
diffend:
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
strategy:
|
46
|
+
fail-fast: false
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@v2
|
49
|
+
with:
|
50
|
+
fetch-depth: 0
|
51
|
+
- name: Set up Ruby
|
52
|
+
uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: 3.0
|
55
|
+
- name: Install latest bundler
|
56
|
+
run: gem install bundler --no-document
|
57
|
+
- name: Install Diffend plugin
|
58
|
+
run: bundle plugin install diffend
|
59
|
+
- name: Bundle Secure
|
60
|
+
run: bundle secure
|
61
|
+
|
62
|
+
coditsu:
|
63
|
+
runs-on: ubuntu-latest
|
64
|
+
strategy:
|
65
|
+
fail-fast: false
|
66
|
+
steps:
|
67
|
+
- uses: actions/checkout@v2
|
68
|
+
with:
|
69
|
+
fetch-depth: 0
|
70
|
+
- name: Run Coditsu
|
71
|
+
run: \curl -sSL https://api.coditsu.io/run/ci | bash
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.1
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Karafka Avro Parser changelog
|
2
|
+
|
3
|
+
## master
|
4
|
+
- [#9](https://github.com/karafka/avro/pull/9) drop support for ruby 2.3
|
5
|
+
- [#2](https://github.com/karafka/avro/pull/2) only support ruby 2.6, 2.5, 2.4
|
6
|
+
|
7
|
+
## 0.2
|
8
|
+
- [#1](https://github.com/karafka/avro/pull/1) allow schema name to be optional when using a registry
|
9
|
+
|
10
|
+
## 0.1
|
11
|
+
- initial release
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
karafka-avro-parser (0.2.0)
|
5
|
+
avro_turf (~> 0.8)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
avro (1.9.2)
|
11
|
+
multi_json
|
12
|
+
avro_turf (0.11.0)
|
13
|
+
avro (>= 1.7.7, < 1.10)
|
14
|
+
excon (~> 0.45)
|
15
|
+
diff-lcs (1.4.4)
|
16
|
+
excon (0.80.1)
|
17
|
+
multi_json (1.15.0)
|
18
|
+
rake (13.0.3)
|
19
|
+
rspec (3.10.0)
|
20
|
+
rspec-core (~> 3.10.0)
|
21
|
+
rspec-expectations (~> 3.10.0)
|
22
|
+
rspec-mocks (~> 3.10.0)
|
23
|
+
rspec-core (3.10.1)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-expectations (3.10.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-mocks (3.10.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.10.0)
|
31
|
+
rspec-support (3.10.2)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
x86_64-darwin
|
35
|
+
x86_64-darwin-19
|
36
|
+
x86_64-linux
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 2)
|
40
|
+
karafka-avro-parser!
|
41
|
+
rake
|
42
|
+
rspec
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
2.2.16
|
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Karafka::Avro::Parser
|
2
|
+
|
3
|
+
Karafka Parser for [Apache Avro](http://avro.apache.org/). It uses the great [AvroTurf](https://github.com/dasch/avro_turf) gem by under the hood.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'karafka-avro-parser'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Thanks to Karafka's modular design, you only have to define a `parser` the moment you draw your consumer groups.
|
20
|
+
|
21
|
+
### Example with Schema Folder
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Karafka::Parsers::Avro.schemas_path = 'app/schemas'
|
25
|
+
|
26
|
+
App.consumer_groups.draw do
|
27
|
+
consumer_group :my_consumer_group do
|
28
|
+
topic :my_topic do
|
29
|
+
consumer AvroConsumer
|
30
|
+
parser Karafka::Parsers::Avro.from_path('schema_name')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
### Example with a Codec
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Karafka::Parsers::Avro.schemas_path = 'app/schemas'
|
40
|
+
|
41
|
+
App.consumer_groups.draw do
|
42
|
+
consumer_group :my_consumer_group do
|
43
|
+
topic :my_topic do
|
44
|
+
consumer AvroConsumer
|
45
|
+
parser Karafka::Parsers::Avro.from_path('schema_name', codec: 'deflate')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
### Example with Schema Registry
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Karafka::Parsers::Avro.registry_url = 'http://my-registry:8081/'
|
55
|
+
|
56
|
+
App.consumer_groups.draw do
|
57
|
+
consumer_group :my_consumer_group do
|
58
|
+
topic :my_topic do
|
59
|
+
consumer AvroConsumer
|
60
|
+
parser Karafka::Parsers::Avro.from_registry('schema_name')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
*Note: `schema_name` is not specifically required when using a schema registry, as the schema id is contained within the message, it can be passed in optionally if you are using one schema per topic*
|
67
|
+
|
68
|
+
## Note on contributions
|
69
|
+
|
70
|
+
First, thank you for considering contributing to Karafka! It's people like you that make the open source community such a great community!
|
71
|
+
|
72
|
+
Each pull request must pass all the RSpec specs and meet our quality requirements.
|
73
|
+
|
74
|
+
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.
|
75
|
+
|
76
|
+
Coditsu will automatically check your work against our quality standards. You can find your commit check results on the [builds page](https://app.coditsu.io/karafka/commit_builds) of Karafka organization.
|
77
|
+
|
78
|
+
[![coditsu](https://coditsu.io/assets/quality_bar.svg)](https://app.coditsu.io/karafka-avro/commit_builds)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "karafka/avro/parser"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'karafka/parsers/avro/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'karafka-avro-parser'
|
10
|
+
spec.version = Karafka::Parsers::Avro::VERSION
|
11
|
+
spec.authors = ['Kacper Madej']
|
12
|
+
spec.email = %w[kacperoza@gmail.com]
|
13
|
+
spec.homepage = 'https://github.com/karafka/avro'
|
14
|
+
spec.summary = 'Apache Avro support for Karafka'
|
15
|
+
spec.description = ''
|
16
|
+
spec.license = 'LGPL-3.0'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.require_paths = %w[lib]
|
22
|
+
|
23
|
+
spec.required_ruby_version = '>= 2.5.0'
|
24
|
+
|
25
|
+
spec.add_dependency 'avro_turf', '~> 0.8'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'rspec'
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avro_turf'
|
4
|
+
require 'avro_turf/messaging'
|
5
|
+
|
6
|
+
require_relative 'avro/parser'
|
7
|
+
require_relative 'avro/version'
|
8
|
+
|
9
|
+
module Karafka
|
10
|
+
module Parsers
|
11
|
+
module Avro
|
12
|
+
def self.registry_url=(registry_url)
|
13
|
+
@registry_url = registry_url
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.schemas_path=(schemas_path)
|
17
|
+
@schemas_path = schemas_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.from_registry(schema_name = nil)
|
21
|
+
raise ArgumentError, 'You have to specify registry_path first' if @registry_url.nil?
|
22
|
+
|
23
|
+
Parser.new(AvroTurf::Messaging.new(registry_url: @registry_url), schema_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.from_path(schema_name, codec: nil)
|
27
|
+
raise ArgumentError, 'You have to specify schemas_path first' if @schemas_path.nil?
|
28
|
+
|
29
|
+
Parser.new(AvroTurf.new(schemas_path: @schemas_path, codec: codec), schema_name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avro_turf'
|
4
|
+
require 'avro_turf/messaging'
|
5
|
+
|
6
|
+
module Karafka
|
7
|
+
module Parsers
|
8
|
+
module Avro
|
9
|
+
class Parser
|
10
|
+
attr_reader :avro, :schema_name
|
11
|
+
|
12
|
+
def initialize(avro, schema_name)
|
13
|
+
@avro = avro
|
14
|
+
@schema_name = schema_name
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse(content)
|
18
|
+
avro.decode(content, schema_name: schema_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate(content)
|
22
|
+
avro.encode(content, schema_name: schema_name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: karafka-avro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kacper Madej
|
8
|
+
- Tomasz Pajor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: avro_turf
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.8'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.8'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description: ''
|
71
|
+
email:
|
72
|
+
- kacperoza@gmail.com
|
73
|
+
- tomek@polishgeeks.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".coditsu/ci.yml"
|
79
|
+
- ".diffend.yml"
|
80
|
+
- ".github/FUNDING.yml"
|
81
|
+
- ".github/workflows/ci.yml"
|
82
|
+
- ".gitignore"
|
83
|
+
- ".rspec"
|
84
|
+
- ".ruby-version"
|
85
|
+
- CHANGELOG.md
|
86
|
+
- Gemfile
|
87
|
+
- Gemfile.lock
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- bin/console
|
92
|
+
- bin/setup
|
93
|
+
- karafka-avro-parser.gemspec
|
94
|
+
- lib/karafka-avro-parser.rb
|
95
|
+
- lib/karafka/parsers/avro.rb
|
96
|
+
- lib/karafka/parsers/avro/parser.rb
|
97
|
+
- lib/karafka/parsers/avro/version.rb
|
98
|
+
homepage: https://github.com/karafka/avro
|
99
|
+
licenses:
|
100
|
+
- LGPL-3.0
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.5.0
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubygems_version: 3.2.15
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Apache Avro support for Karafka
|
121
|
+
test_files: []
|