karafka 1.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.coditsu.yml +3 -0
  3. data/.console_irbrc +13 -0
  4. data/.gitignore +68 -0
  5. data/.rspec +1 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +49 -0
  9. data/CHANGELOG.md +458 -0
  10. data/CODE_OF_CONDUCT.md +46 -0
  11. data/CONTRIBUTING.md +41 -0
  12. data/Gemfile +15 -0
  13. data/Gemfile.lock +126 -0
  14. data/MIT-LICENCE +18 -0
  15. data/README.md +102 -0
  16. data/bin/karafka +19 -0
  17. data/config/errors.yml +6 -0
  18. data/karafka.gemspec +42 -0
  19. data/lib/karafka.rb +79 -0
  20. data/lib/karafka/app.rb +45 -0
  21. data/lib/karafka/attributes_map.rb +69 -0
  22. data/lib/karafka/backends/inline.rb +16 -0
  23. data/lib/karafka/base_consumer.rb +68 -0
  24. data/lib/karafka/base_responder.rb +208 -0
  25. data/lib/karafka/callbacks.rb +30 -0
  26. data/lib/karafka/callbacks/config.rb +22 -0
  27. data/lib/karafka/callbacks/dsl.rb +16 -0
  28. data/lib/karafka/cli.rb +54 -0
  29. data/lib/karafka/cli/base.rb +78 -0
  30. data/lib/karafka/cli/console.rb +29 -0
  31. data/lib/karafka/cli/flow.rb +46 -0
  32. data/lib/karafka/cli/info.rb +29 -0
  33. data/lib/karafka/cli/install.rb +42 -0
  34. data/lib/karafka/cli/server.rb +66 -0
  35. data/lib/karafka/connection/api_adapter.rb +148 -0
  36. data/lib/karafka/connection/builder.rb +16 -0
  37. data/lib/karafka/connection/client.rb +107 -0
  38. data/lib/karafka/connection/delegator.rb +46 -0
  39. data/lib/karafka/connection/listener.rb +60 -0
  40. data/lib/karafka/consumers/callbacks.rb +54 -0
  41. data/lib/karafka/consumers/includer.rb +51 -0
  42. data/lib/karafka/consumers/responders.rb +24 -0
  43. data/lib/karafka/consumers/single_params.rb +15 -0
  44. data/lib/karafka/errors.rb +50 -0
  45. data/lib/karafka/fetcher.rb +44 -0
  46. data/lib/karafka/helpers/class_matcher.rb +78 -0
  47. data/lib/karafka/helpers/config_retriever.rb +46 -0
  48. data/lib/karafka/helpers/multi_delegator.rb +33 -0
  49. data/lib/karafka/instrumentation/listener.rb +112 -0
  50. data/lib/karafka/instrumentation/logger.rb +55 -0
  51. data/lib/karafka/instrumentation/monitor.rb +64 -0
  52. data/lib/karafka/loader.rb +28 -0
  53. data/lib/karafka/params/dsl.rb +158 -0
  54. data/lib/karafka/params/params_batch.rb +46 -0
  55. data/lib/karafka/parsers/json.rb +38 -0
  56. data/lib/karafka/patches/dry_configurable.rb +33 -0
  57. data/lib/karafka/patches/ruby_kafka.rb +34 -0
  58. data/lib/karafka/persistence/client.rb +25 -0
  59. data/lib/karafka/persistence/consumer.rb +38 -0
  60. data/lib/karafka/persistence/topic.rb +29 -0
  61. data/lib/karafka/process.rb +62 -0
  62. data/lib/karafka/responders/builder.rb +36 -0
  63. data/lib/karafka/responders/topic.rb +57 -0
  64. data/lib/karafka/routing/builder.rb +61 -0
  65. data/lib/karafka/routing/consumer_group.rb +61 -0
  66. data/lib/karafka/routing/consumer_mapper.rb +34 -0
  67. data/lib/karafka/routing/proxy.rb +37 -0
  68. data/lib/karafka/routing/router.rb +29 -0
  69. data/lib/karafka/routing/topic.rb +60 -0
  70. data/lib/karafka/routing/topic_mapper.rb +55 -0
  71. data/lib/karafka/schemas/config.rb +24 -0
  72. data/lib/karafka/schemas/consumer_group.rb +78 -0
  73. data/lib/karafka/schemas/consumer_group_topic.rb +18 -0
  74. data/lib/karafka/schemas/responder_usage.rb +39 -0
  75. data/lib/karafka/schemas/server_cli_options.rb +43 -0
  76. data/lib/karafka/server.rb +85 -0
  77. data/lib/karafka/setup/config.rb +193 -0
  78. data/lib/karafka/setup/configurators/base.rb +29 -0
  79. data/lib/karafka/setup/configurators/params.rb +25 -0
  80. data/lib/karafka/setup/configurators/water_drop.rb +32 -0
  81. data/lib/karafka/setup/dsl.rb +22 -0
  82. data/lib/karafka/status.rb +25 -0
  83. data/lib/karafka/templates/application_consumer.rb.example +6 -0
  84. data/lib/karafka/templates/application_responder.rb.example +11 -0
  85. data/lib/karafka/templates/karafka.rb.example +54 -0
  86. data/lib/karafka/version.rb +7 -0
  87. data/log/.gitkeep +0 -0
  88. metadata +303 -0
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at maciej@coditsu.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,41 @@
1
+ # Contribute
2
+
3
+ ## Introduction
4
+
5
+ First, thank you for considering contributing to karafka! It's people like you that make the open source community such a great community! 😊
6
+
7
+ We welcome any type of contribution, not only code. You can help with
8
+ - **QA**: file bug reports, the more details you can give the better (e.g. screenshots with the console open)
9
+ - **Marketing**: writing blog posts, howto's, printing stickers, ...
10
+ - **Community**: presenting the project at meetups, organizing a dedicated meetup for the local community, ...
11
+ - **Code**: take a look at the [open issues](issues). Even if you can't write code, commenting on them, showing that you care about a given issue matters. It helps us triage them.
12
+
13
+ ## Your First Contribution
14
+
15
+ Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
16
+
17
+ ## Submitting code
18
+
19
+ Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it. The pull request should also contain tests.
20
+
21
+ ## Code review process
22
+
23
+ Each pull request must pass all the rspec specs and meet our quality requirements.
24
+
25
+ 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.
26
+
27
+ 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.
28
+
29
+ [![coditsu](https://coditsu.io/assets/quality_bar.svg)](https://app.coditsu.io/karafka/commit_builds)
30
+
31
+ ## Questions
32
+
33
+ If you have any questions, create an [issue](issue) (protip: do a quick search first to see if someone else didn't ask the same question before!).
34
+ You can also reach us at hello@karafka.opencollective.com.
35
+
36
+ ## Credits
37
+
38
+ ### Contributors
39
+
40
+ Thank you to all the people who have already contributed to karafka!
41
+ <a href="graphs/contributors"><img src="https://opencollective.com/karafka/contributors.svg?width=890" /></a>
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'benchmark-ips'
9
+ end
10
+
11
+ group :test do
12
+ gem 'rspec'
13
+ gem 'simplecov'
14
+ gem 'timecop'
15
+ end
@@ -0,0 +1,126 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ karafka (1.2.11)
5
+ activesupport (>= 4.0)
6
+ dry-configurable (~> 0.8)
7
+ dry-inflector (~> 0.1)
8
+ dry-monitor (~> 0.3)
9
+ dry-validation (~> 0.11)
10
+ envlogic (~> 1.0)
11
+ multi_json (>= 1.12)
12
+ rake (>= 11.3)
13
+ require_all (>= 1.4)
14
+ ruby-kafka (>= 0.6)
15
+ thor (~> 0.20)
16
+ waterdrop (~> 1.2.4)
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ activesupport (5.2.2)
22
+ concurrent-ruby (~> 1.0, >= 1.0.2)
23
+ i18n (>= 0.7, < 2)
24
+ minitest (~> 5.1)
25
+ tzinfo (~> 1.1)
26
+ benchmark-ips (2.7.2)
27
+ concurrent-ruby (1.1.4)
28
+ delivery_boy (0.2.7)
29
+ king_konf (~> 0.2)
30
+ ruby-kafka (~> 0.5)
31
+ diff-lcs (1.3)
32
+ digest-crc (0.4.1)
33
+ docile (1.3.1)
34
+ dry-configurable (0.8.0)
35
+ concurrent-ruby (~> 1.0)
36
+ dry-core (~> 0.4, >= 0.4.7)
37
+ dry-container (0.7.0)
38
+ concurrent-ruby (~> 1.0)
39
+ dry-configurable (~> 0.1, >= 0.1.3)
40
+ dry-core (0.4.7)
41
+ concurrent-ruby (~> 1.0)
42
+ dry-equalizer (0.2.1)
43
+ dry-events (0.1.0)
44
+ concurrent-ruby (~> 1.0)
45
+ dry-core (~> 0.4)
46
+ dry-equalizer (~> 0.2)
47
+ dry-inflector (0.1.2)
48
+ dry-logic (0.5.0)
49
+ dry-container (~> 0.2, >= 0.2.6)
50
+ dry-core (~> 0.2)
51
+ dry-equalizer (~> 0.2)
52
+ dry-monitor (0.3.0)
53
+ dry-configurable (~> 0.5)
54
+ dry-core (~> 0.4)
55
+ dry-equalizer (~> 0.2)
56
+ dry-events (~> 0.1)
57
+ dry-types (0.14.0)
58
+ concurrent-ruby (~> 1.0)
59
+ dry-container (~> 0.3)
60
+ dry-core (~> 0.4, >= 0.4.4)
61
+ dry-equalizer (~> 0.2)
62
+ dry-inflector (~> 0.1, >= 0.1.2)
63
+ dry-logic (~> 0.5, >= 0.5)
64
+ dry-validation (0.13.0)
65
+ concurrent-ruby (~> 1.0)
66
+ dry-configurable (~> 0.1, >= 0.1.3)
67
+ dry-core (~> 0.2, >= 0.2.1)
68
+ dry-equalizer (~> 0.2)
69
+ dry-logic (~> 0.5, >= 0.5.0)
70
+ dry-types (~> 0.14, >= 0.14)
71
+ envlogic (1.1.0)
72
+ dry-inflector (~> 0.1)
73
+ i18n (1.5.3)
74
+ concurrent-ruby (~> 1.0)
75
+ json (2.1.0)
76
+ king_konf (0.3.7)
77
+ minitest (5.11.3)
78
+ multi_json (1.13.1)
79
+ null-logger (0.1.5)
80
+ rake (12.3.2)
81
+ require_all (2.0.0)
82
+ rspec (3.8.0)
83
+ rspec-core (~> 3.8.0)
84
+ rspec-expectations (~> 3.8.0)
85
+ rspec-mocks (~> 3.8.0)
86
+ rspec-core (3.8.0)
87
+ rspec-support (~> 3.8.0)
88
+ rspec-expectations (3.8.2)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.8.0)
91
+ rspec-mocks (3.8.0)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.8.0)
94
+ rspec-support (3.8.0)
95
+ ruby-kafka (0.7.5)
96
+ digest-crc
97
+ simplecov (0.16.1)
98
+ docile (~> 1.1)
99
+ json (>= 1.8, < 3)
100
+ simplecov-html (~> 0.10.0)
101
+ simplecov-html (0.10.2)
102
+ thor (0.20.3)
103
+ thread_safe (0.3.6)
104
+ timecop (0.9.1)
105
+ tzinfo (1.2.5)
106
+ thread_safe (~> 0.1)
107
+ waterdrop (1.2.5)
108
+ delivery_boy (~> 0.2)
109
+ dry-configurable (~> 0.8)
110
+ dry-monitor (~> 0.3)
111
+ dry-validation (~> 0.11)
112
+ null-logger (~> 0.1)
113
+ ruby-kafka (>= 0.6)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ benchmark-ips
120
+ karafka!
121
+ rspec
122
+ simplecov
123
+ timecop
124
+
125
+ BUNDLED WITH
126
+ 2.0.1
@@ -0,0 +1,18 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining
2
+ a copy of this software and associated documentation files (the
3
+ "Software"), to deal in the Software without restriction, including
4
+ without limitation the rights to use, copy, modify, merge, publish,
5
+ distribute, sublicense, and/or sell copies of the Software, and to
6
+ permit persons to whom the Software is furnished to do so, subject to
7
+ the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be
10
+ included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,102 @@
1
+ ![karafka logo](https://raw.githubusercontent.com/karafka/misc/master/logo/karafka_logotype_transparent2.png)
2
+
3
+ [![Build Status](https://travis-ci.org/karafka/karafka.svg?branch=master)](https://travis-ci.org/karafka/karafka)
4
+
5
+ Framework used to simplify Apache Kafka based Ruby applications development.
6
+
7
+ Karafka allows you to capture everything that happens in your systems in large scale, providing you with a seamless and stable core for consuming and processing this data, without having to focus on things that are not your business domain.
8
+
9
+ Karafka not only handles incoming messages but also provides tools for building complex data-flow applications that receive and send messages.
10
+
11
+ ## How does it work
12
+
13
+ Karafka provides a higher-level abstraction that allows you to focus on your business logic development, instead of focusing on implementing lower level abstraction layers. It provides developers with a set of tools that are dedicated for building multi-topic applications similar to how Rails applications are being built.
14
+
15
+ ### Some things you might wonder about:
16
+
17
+ - You can integrate Karafka with **any** Ruby-based application.
18
+ - Karafka does **not** require Sidekiq or any other third party software (apart from Kafka itself).
19
+ - Karafka works with Ruby on Rails but it is a **standalone** framework that can work without it.
20
+ - Karafka has a **minimal** set of dependencies, so adding it won't be a huge burden for your already existing applications.
21
+ - Karafka processes can be executed for a **given subset** of consumer groups and/or topics, so you can fine tune it depending on your business logic.
22
+
23
+ Karafka based applications can be easily deployed to any type of infrastructure, including those based on:
24
+
25
+ * Heroku
26
+ * Capistrano
27
+ * Docker
28
+ * Terraform
29
+
30
+ ## Kafka 0.10 or prior
31
+
32
+ If you're using Kafka 0.10, please lock `ruby-kafka` gem in your Gemfile to version `0.6.8`:
33
+
34
+ ```ruby
35
+ gem 'karafka'
36
+ gem 'ruby-kafka', '~> 0.6.8'
37
+ ```
38
+
39
+ ## Support
40
+
41
+ Karafka has a [Wiki pages](https://github.com/karafka/karafka/wiki) for almost everything and a pretty decent [FAQ](https://github.com/karafka/karafka/wiki/FAQ). It covers the whole installation, setup, and deployment along with other useful details on how to run Karafka.
42
+
43
+ If you have any questions about using Karafka, feel free to join our [Gitter](https://gitter.im/karafka/karafka) chat channel.
44
+
45
+ ## Getting started
46
+
47
+ If you're completely new to the subject, you can start with our "Kafka on Rails" articles series, that will get you up and running with the terminology and basic ideas behind using Kafka:
48
+
49
+ - [Kafka on Rails: Using Kafka with Ruby on Rails – Part 1 – Kafka basics and its advantages](https://mensfeld.pl/2017/11/kafka-on-rails-using-kafka-with-ruby-on-rails-part-1-kafka-basics-and-its-advantages/)
50
+ - [Kafka on Rails: Using Kafka with Ruby on Rails – Part 2 – Getting started with Ruby and Kafka](https://mensfeld.pl/2018/01/kafka-on-rails-using-kafka-with-ruby-on-rails-part-2-getting-started-with-ruby-and-kafka/)
51
+
52
+ If you want to get started with Kafka and Karafka as fast as possible, then the best idea is to just clone our example repository:
53
+
54
+ ```bash
55
+ git clone https://github.com/karafka/karafka-example-app ./example_app
56
+ ```
57
+
58
+ then, just bundle install all the dependencies:
59
+
60
+ ```bash
61
+ cd ./example_app
62
+ bundle install
63
+ ```
64
+
65
+ and follow the instructions from the [example app Wiki](https://github.com/karafka/karafka-example-app/blob/master/README.md).
66
+
67
+ **Note**: you need to ensure, that you have Kafka up and running and you need to configure Kafka seed_brokers in the ```karafka.rb``` file.
68
+
69
+ If you need more details and know how on how to start Karafka with a clean installation, read the [Getting started page](https://github.com/karafka/karafka/wiki/Getting-started) section of our Wiki.
70
+
71
+ ## Notice
72
+
73
+ Karafka framework and Karafka team are __not__ related to Kafka streaming service called CloudKarafka in any matter. We don't recommend nor discourage usage of their platform.
74
+
75
+ ## References
76
+
77
+ * [Karafka framework](https://github.com/karafka/karafka)
78
+ * [Karafka Travis CI](https://travis-ci.org/karafka/karafka)
79
+ * [Karafka Coditsu](https://app.coditsu.io/karafka/repositories/karafka)
80
+
81
+ ## Note on contributions
82
+
83
+ First, thank you for considering contributing to Karafka! It's people like you that make the open source community such a great community!
84
+
85
+ Each pull request must pass all the RSpec specs and meet our quality requirements.
86
+
87
+ 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.
88
+
89
+ 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.
90
+
91
+ [![coditsu](https://coditsu.io/assets/quality_bar.svg)](https://app.coditsu.io/karafka/commit_builds)
92
+
93
+ ## Contributors
94
+
95
+ This project exists thanks to all the people who contribute.
96
+ <a href="https://github.com/karafka/karafka/graphs/contributors"><img src="https://opencollective.com/karafka/contributors.svg?width=890" /></a>
97
+
98
+ ## Sponsors
99
+
100
+ We are looking for sustainable sponsorship. If your company is relying on Karafka framework or simply want to see Karafka evolve faster to meet your requirements, please consider backing the project.
101
+
102
+ Please contact [Maciej Mensfeld](mailto:maciej@coditsu.io) directly for more details.
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'karafka'
4
+
5
+ # If there is a boot file, we need to require it as we expect it to contain
6
+ # Karafka app setup, routes, etc
7
+ if File.exist?(Karafka.boot_file)
8
+ require Karafka.boot_file.to_s
9
+ else
10
+ # However when it is unavailable, we still want to be able to run help command
11
+ # and install command as they don't require configured app itself to run
12
+ raise(
13
+ Karafka::Errors::MissingBootFile,
14
+ Karafka.boot_file
15
+ ) unless %w[-h install].include?(ARGV[0])
16
+ end
17
+
18
+ Karafka::Cli.prepare
19
+ Karafka::Cli.start
@@ -0,0 +1,6 @@
1
+ en:
2
+ errors:
3
+ broker_schema?: >
4
+ has an invalid format.
5
+ Expected schema, host and port number.
6
+ Example: kafka://127.0.0.1:9092 or kafka+ssl://127.0.0.1:9092
@@ -0,0 +1,42 @@
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/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'karafka'
10
+ spec.version = ::Karafka::VERSION
11
+ spec.platform = Gem::Platform::RUBY
12
+ spec.authors = ['Maciej Mensfeld', 'Pavlo Vavruk', 'Adam Gwozdowski']
13
+ spec.email = %w[maciej@coditsu.io pavlo.vavruk@gmail.com adam99g@gmail.com]
14
+ spec.homepage = 'https://github.com/karafka/karafka'
15
+ spec.summary = 'Ruby based framework for working with Apache Kafka'
16
+ spec.description = 'Framework used to simplify Apache Kafka based Ruby applications development'
17
+ spec.license = 'MIT'
18
+
19
+ spec.add_dependency 'activesupport', '>= 4.0'
20
+ spec.add_dependency 'dry-configurable', '~> 0.8'
21
+ spec.add_dependency 'dry-inflector', '~> 0.1'
22
+ spec.add_dependency 'dry-monitor', '~> 0.3'
23
+ spec.add_dependency 'dry-validation', '~> 0.11'
24
+ spec.add_dependency 'envlogic', '~> 1.0'
25
+ spec.add_dependency 'multi_json', '>= 1.12'
26
+ spec.add_dependency 'rake', '>= 11.3'
27
+ spec.add_dependency 'require_all', '>= 1.4'
28
+ spec.add_dependency 'ruby-kafka', '>= 0.6'
29
+ spec.add_dependency 'thor', '~> 0.20'
30
+ spec.add_dependency 'waterdrop', '~> 1.2.4'
31
+
32
+ spec.post_install_message = <<~MSG
33
+ \e[93mWarning:\e[0m If you're using Kafka 0.10, please lock ruby-kafka in your Gemfile to version '0.6.8':
34
+ gem 'ruby-kafka', '~> 0.6.8'
35
+ MSG
36
+
37
+ spec.required_ruby_version = '>= 2.3.0'
38
+
39
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
40
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
41
+ spec.require_paths = %w[lib]
42
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ English
5
+ waterdrop
6
+ kafka
7
+ envlogic
8
+ thor
9
+ forwardable
10
+ fileutils
11
+ multi_json
12
+ require_all
13
+ dry-configurable
14
+ dry-validation
15
+ dry/inflector
16
+ dry/monitor/notifications
17
+ active_support/callbacks
18
+ karafka/loader
19
+ ].each(&method(:require))
20
+
21
+ # Karafka library
22
+ module Karafka
23
+ extend Envlogic
24
+
25
+ class << self
26
+ # @return [Logger] logger that we want to use. Will use ::Karafka::Logger by default
27
+ def logger
28
+ @logger ||= App.config.logger
29
+ end
30
+
31
+ # @return [::Karafka::Monitor] monitor that we want to use
32
+ def monitor
33
+ @monitor ||= App.config.monitor
34
+ end
35
+
36
+ # @return [String] root path of this gem
37
+ def gem_root
38
+ Pathname.new(File.expand_path('..', __dir__))
39
+ end
40
+
41
+ # @return [String] Karafka app root path (user application path)
42
+ def root
43
+ Pathname.new(ENV['KARAFKA_ROOT_DIR'] || File.dirname(ENV['BUNDLE_GEMFILE']))
44
+ end
45
+
46
+ # @return [String] path to Karafka gem root core
47
+ def core_root
48
+ Pathname.new(File.expand_path('karafka', __dir__))
49
+ end
50
+
51
+ # @return [String] path to a default file that contains booting procedure etc
52
+ # @note By default it is a file called 'karafka.rb' but it can be specified as you wish if you
53
+ # have Karafka that is merged into a Sinatra/Rails app and karafka.rb is taken.
54
+ # It will be used for console/consumers/etc
55
+ # @example Standard only-Karafka case
56
+ # Karafka.boot_file #=> '/home/app_path/karafka.rb'
57
+ # @example Non standard case
58
+ # KARAFKA_BOOT_FILE='/home/app_path/app.rb'
59
+ # Karafka.boot_file #=> '/home/app_path/app.rb'
60
+ def boot_file
61
+ Pathname.new(ENV['KARAFKA_BOOT_FILE'] || File.join(Karafka.root, 'karafka.rb'))
62
+ end
63
+ end
64
+ end
65
+
66
+ %w[
67
+ callbacks
68
+ callbacks/*
69
+ setup/dsl
70
+ setup/config
71
+ status
72
+ schemas/config
73
+ schemas/consumer_group_topic
74
+ schemas/consumer_group
75
+ ].each { |path| require_all File.join(Karafka.core_root, path + '.rb') }
76
+
77
+ Karafka::Loader.load!(Karafka.core_root)
78
+ Kafka::Consumer.prepend(Karafka::Patches::RubyKafka)
79
+ Dry::Configurable::Config.prepend(Karafka::Patches::DryConfigurable)