karafka 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.console_irbrc +13 -0
  3. data/.gitignore +68 -0
  4. data/.rspec +1 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +18 -0
  8. data/CHANGELOG.md +415 -0
  9. data/CODE_OF_CONDUCT.md +46 -0
  10. data/CONTRIBUTING.md +41 -0
  11. data/Gemfile +11 -0
  12. data/Gemfile.lock +123 -0
  13. data/MIT-LICENCE +18 -0
  14. data/README.md +89 -0
  15. data/bin/karafka +19 -0
  16. data/config/errors.yml +6 -0
  17. data/karafka.gemspec +37 -0
  18. data/lib/karafka.rb +78 -0
  19. data/lib/karafka/app.rb +45 -0
  20. data/lib/karafka/attributes_map.rb +67 -0
  21. data/lib/karafka/backends/inline.rb +16 -0
  22. data/lib/karafka/base_consumer.rb +68 -0
  23. data/lib/karafka/base_responder.rb +204 -0
  24. data/lib/karafka/callbacks.rb +30 -0
  25. data/lib/karafka/callbacks/config.rb +22 -0
  26. data/lib/karafka/callbacks/dsl.rb +16 -0
  27. data/lib/karafka/cli.rb +54 -0
  28. data/lib/karafka/cli/base.rb +78 -0
  29. data/lib/karafka/cli/console.rb +29 -0
  30. data/lib/karafka/cli/flow.rb +46 -0
  31. data/lib/karafka/cli/info.rb +29 -0
  32. data/lib/karafka/cli/install.rb +42 -0
  33. data/lib/karafka/cli/server.rb +66 -0
  34. data/lib/karafka/connection/client.rb +117 -0
  35. data/lib/karafka/connection/config_adapter.rb +120 -0
  36. data/lib/karafka/connection/delegator.rb +46 -0
  37. data/lib/karafka/connection/listener.rb +60 -0
  38. data/lib/karafka/consumers/callbacks.rb +54 -0
  39. data/lib/karafka/consumers/includer.rb +51 -0
  40. data/lib/karafka/consumers/responders.rb +24 -0
  41. data/lib/karafka/consumers/single_params.rb +15 -0
  42. data/lib/karafka/errors.rb +50 -0
  43. data/lib/karafka/fetcher.rb +44 -0
  44. data/lib/karafka/helpers/class_matcher.rb +78 -0
  45. data/lib/karafka/helpers/config_retriever.rb +46 -0
  46. data/lib/karafka/helpers/multi_delegator.rb +33 -0
  47. data/lib/karafka/instrumentation/listener.rb +112 -0
  48. data/lib/karafka/instrumentation/logger.rb +55 -0
  49. data/lib/karafka/instrumentation/monitor.rb +64 -0
  50. data/lib/karafka/loader.rb +28 -0
  51. data/lib/karafka/params/dsl.rb +156 -0
  52. data/lib/karafka/params/params_batch.rb +46 -0
  53. data/lib/karafka/parsers/json.rb +38 -0
  54. data/lib/karafka/patches/dry_configurable.rb +35 -0
  55. data/lib/karafka/patches/ruby_kafka.rb +34 -0
  56. data/lib/karafka/persistence/client.rb +25 -0
  57. data/lib/karafka/persistence/consumer.rb +38 -0
  58. data/lib/karafka/persistence/topic.rb +29 -0
  59. data/lib/karafka/process.rb +64 -0
  60. data/lib/karafka/responders/builder.rb +36 -0
  61. data/lib/karafka/responders/topic.rb +57 -0
  62. data/lib/karafka/routing/builder.rb +61 -0
  63. data/lib/karafka/routing/consumer_group.rb +61 -0
  64. data/lib/karafka/routing/consumer_mapper.rb +34 -0
  65. data/lib/karafka/routing/proxy.rb +37 -0
  66. data/lib/karafka/routing/router.rb +29 -0
  67. data/lib/karafka/routing/topic.rb +60 -0
  68. data/lib/karafka/routing/topic_mapper.rb +55 -0
  69. data/lib/karafka/schemas/config.rb +24 -0
  70. data/lib/karafka/schemas/consumer_group.rb +77 -0
  71. data/lib/karafka/schemas/consumer_group_topic.rb +18 -0
  72. data/lib/karafka/schemas/responder_usage.rb +39 -0
  73. data/lib/karafka/schemas/server_cli_options.rb +43 -0
  74. data/lib/karafka/server.rb +94 -0
  75. data/lib/karafka/setup/config.rb +189 -0
  76. data/lib/karafka/setup/configurators/base.rb +29 -0
  77. data/lib/karafka/setup/configurators/params.rb +25 -0
  78. data/lib/karafka/setup/configurators/water_drop.rb +32 -0
  79. data/lib/karafka/setup/dsl.rb +22 -0
  80. data/lib/karafka/status.rb +25 -0
  81. data/lib/karafka/templates/application_consumer.rb.example +6 -0
  82. data/lib/karafka/templates/application_responder.rb.example +11 -0
  83. data/lib/karafka/templates/karafka.rb.example +54 -0
  84. data/lib/karafka/version.rb +7 -0
  85. data/log/.gitkeep +0 -0
  86. metadata +301 -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,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'rspec'
9
+ gem 'simplecov'
10
+ gem 'timecop'
11
+ end
@@ -0,0 +1,123 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ karafka (1.2.0)
5
+ activesupport (>= 4.0)
6
+ dry-configurable (~> 0.7)
7
+ dry-inflector (~> 0.1.1)
8
+ dry-monitor (~> 0.1)
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.5.3)
15
+ thor (~> 0.19)
16
+ waterdrop (~> 1.2)
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ activesupport (5.1.5)
22
+ concurrent-ruby (~> 1.0, >= 1.0.2)
23
+ i18n (~> 0.7)
24
+ minitest (~> 5.1)
25
+ tzinfo (~> 1.1)
26
+ concurrent-ruby (1.0.5)
27
+ delivery_boy (0.2.4)
28
+ king_konf (~> 0.1.8)
29
+ ruby-kafka (~> 0.5.1)
30
+ diff-lcs (1.3)
31
+ docile (1.3.0)
32
+ dry-configurable (0.7.0)
33
+ concurrent-ruby (~> 1.0)
34
+ dry-container (0.6.0)
35
+ concurrent-ruby (~> 1.0)
36
+ dry-configurable (~> 0.1, >= 0.1.3)
37
+ dry-core (0.4.5)
38
+ concurrent-ruby (~> 1.0)
39
+ dry-equalizer (0.2.0)
40
+ dry-events (0.1.0)
41
+ concurrent-ruby (~> 1.0)
42
+ dry-core (~> 0.4)
43
+ dry-equalizer (~> 0.2)
44
+ dry-inflector (0.1.1)
45
+ dry-logic (0.4.2)
46
+ dry-container (~> 0.2, >= 0.2.6)
47
+ dry-core (~> 0.2)
48
+ dry-equalizer (~> 0.2)
49
+ dry-monitor (0.1.2)
50
+ dry-configurable (~> 0.5)
51
+ dry-equalizer (~> 0.2)
52
+ dry-events (~> 0.1)
53
+ rouge (~> 2.0, >= 2.2.1)
54
+ dry-types (0.12.2)
55
+ concurrent-ruby (~> 1.0)
56
+ dry-configurable (~> 0.1)
57
+ dry-container (~> 0.3)
58
+ dry-core (~> 0.2, >= 0.2.1)
59
+ dry-equalizer (~> 0.2)
60
+ dry-logic (~> 0.4, >= 0.4.2)
61
+ inflecto (~> 0.0.0, >= 0.0.2)
62
+ dry-validation (0.11.1)
63
+ concurrent-ruby (~> 1.0)
64
+ dry-configurable (~> 0.1, >= 0.1.3)
65
+ dry-core (~> 0.2, >= 0.2.1)
66
+ dry-equalizer (~> 0.2)
67
+ dry-logic (~> 0.4, >= 0.4.0)
68
+ dry-types (~> 0.12.0)
69
+ envlogic (1.1.0)
70
+ dry-inflector (~> 0.1)
71
+ i18n (0.9.5)
72
+ concurrent-ruby (~> 1.0)
73
+ inflecto (0.0.2)
74
+ json (2.1.0)
75
+ king_konf (0.1.10)
76
+ minitest (5.11.3)
77
+ multi_json (1.13.1)
78
+ null-logger (0.1.5)
79
+ rake (12.3.1)
80
+ require_all (2.0.0)
81
+ rouge (2.2.1)
82
+ rspec (3.7.0)
83
+ rspec-core (~> 3.7.0)
84
+ rspec-expectations (~> 3.7.0)
85
+ rspec-mocks (~> 3.7.0)
86
+ rspec-core (3.7.1)
87
+ rspec-support (~> 3.7.0)
88
+ rspec-expectations (3.7.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.7.0)
91
+ rspec-mocks (3.7.0)
92
+ diff-lcs (>= 1.2.0, < 2.0)
93
+ rspec-support (~> 3.7.0)
94
+ rspec-support (3.7.1)
95
+ ruby-kafka (0.5.4)
96
+ simplecov (0.16.1)
97
+ docile (~> 1.1)
98
+ json (>= 1.8, < 3)
99
+ simplecov-html (~> 0.10.0)
100
+ simplecov-html (0.10.2)
101
+ thor (0.20.0)
102
+ thread_safe (0.3.6)
103
+ timecop (0.9.1)
104
+ tzinfo (1.2.5)
105
+ thread_safe (~> 0.1)
106
+ waterdrop (1.2.0)
107
+ delivery_boy (~> 0.2)
108
+ dry-configurable (~> 0.7)
109
+ dry-monitor (~> 0.1)
110
+ dry-validation (~> 0.11)
111
+ null-logger
112
+
113
+ PLATFORMS
114
+ ruby
115
+
116
+ DEPENDENCIES
117
+ karafka!
118
+ rspec
119
+ simplecov
120
+ timecop
121
+
122
+ BUNDLED WITH
123
+ 1.16.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,89 @@
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
+ **Warning**: Wiki and all the docs refer to the 1.2.0.beta4. Sorry for the inconvenience. We will release the stable 1.2.0 version soon.
12
+
13
+ ## How does it work
14
+
15
+ 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 similarly to how Rails applications are being built.
16
+
17
+ ### Some things you might wonder about:
18
+
19
+ - You can integrate Karafka with **any** Ruby based application.
20
+ - Karafka does **not** require Sidekiq or any other third party software (apart from Kafka itself).
21
+ - Karafka works with Ruby on Rails but it is a **standalone** framework that can work without it.
22
+ - Karafka has a **minimal** set of dependencies, so adding it won't be a huge burden for your already existing applications.
23
+ - 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.
24
+
25
+ Karafka based applications can be easily deployed to any type of infrastructure, including those based on:
26
+
27
+ * Heroku
28
+ * Capistrano
29
+ * Docker
30
+
31
+ ## Support
32
+
33
+ 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.
34
+
35
+ If you have any questions about using Karafka, feel free to join our [Gitter](https://gitter.im/karafka/karafka) chat channel.
36
+
37
+ ## Getting started
38
+
39
+ 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:
40
+
41
+ ```bash
42
+ git clone https://github.com/karafka/karafka-example-app ./example_app
43
+ ```
44
+
45
+ then, just bundle install all the dependencies:
46
+
47
+ ```bash
48
+ cd ./example_app
49
+ bundle install
50
+ ```
51
+
52
+ and follow the instructions from the [example app Wiki](https://github.com/karafka/karafka-example-app/blob/master/README.md).
53
+
54
+ **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.
55
+
56
+ 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.
57
+
58
+ ## Notice
59
+
60
+ 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.
61
+
62
+ ## References
63
+
64
+ * [Karafka framework](https://github.com/karafka/karafka)
65
+ * [Karafka Travis CI](https://travis-ci.org/karafka/karafka)
66
+ * [Karafka Coditsu](https://app.coditsu.io/karafka/repositories/karafka)
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/commit_builds)
79
+
80
+ ## Contributors
81
+
82
+ This project exists thanks to all the people who contribute.
83
+ <a href="https://github.com/karafka/karafka/graphs/contributors"><img src="https://opencollective.com/karafka/contributors.svg?width=890" /></a>
84
+
85
+ ## Sponsors
86
+
87
+ 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.
88
+
89
+ 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,37 @@
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.7'
21
+ spec.add_dependency 'dry-inflector', '~> 0.1.1'
22
+ spec.add_dependency 'dry-monitor', '~> 0.1'
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.5.3'
29
+ spec.add_dependency 'thor', '~> 0.19'
30
+ spec.add_dependency 'waterdrop', '~> 1.2'
31
+
32
+ spec.required_ruby_version = '>= 2.3.0'
33
+
34
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
35
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
36
+ spec.require_paths = %w[lib]
37
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ %w[
4
+ English
5
+ waterdrop
6
+ kafka
7
+ envlogic
8
+ thor
9
+ fileutils
10
+ multi_json
11
+ require_all
12
+ dry-configurable
13
+ dry-validation
14
+ dry/inflector
15
+ dry/monitor/notifications
16
+ active_support/callbacks
17
+ karafka/loader
18
+ ].each(&method(:require))
19
+
20
+ # Karafka library
21
+ module Karafka
22
+ extend Envlogic
23
+
24
+ class << self
25
+ # @return [Logger] logger that we want to use. Will use ::Karafka::Logger by default
26
+ def logger
27
+ @logger ||= App.config.logger
28
+ end
29
+
30
+ # @return [::Karafka::Monitor] monitor that we want to use
31
+ def monitor
32
+ @monitor ||= App.config.monitor
33
+ end
34
+
35
+ # @return [String] root path of this gem
36
+ def gem_root
37
+ Pathname.new(File.expand_path('..', __dir__))
38
+ end
39
+
40
+ # @return [String] Karafka app root path (user application path)
41
+ def root
42
+ Pathname.new(ENV['KARAFKA_ROOT_DIR'] || File.dirname(ENV['BUNDLE_GEMFILE']))
43
+ end
44
+
45
+ # @return [String] path to Karafka gem root core
46
+ def core_root
47
+ Pathname.new(File.expand_path('karafka', __dir__))
48
+ end
49
+
50
+ # @return [String] path to a default file that contains booting procedure etc
51
+ # @note By default it is a file called 'karafka.rb' but it can be specified as you wish if you
52
+ # have Karafka that is merged into a Sinatra/Rails app and karafka.rb is taken.
53
+ # It will be used for console/consumers/etc
54
+ # @example Standard only-Karafka case
55
+ # Karafka.boot_file #=> '/home/app_path/karafka.rb'
56
+ # @example Non standard case
57
+ # KARAFKA_BOOT_FILE='/home/app_path/app.rb'
58
+ # Karafka.boot_file #=> '/home/app_path/app.rb'
59
+ def boot_file
60
+ Pathname.new(ENV['KARAFKA_BOOT_FILE'] || File.join(Karafka.root, 'karafka.rb'))
61
+ end
62
+ end
63
+ end
64
+
65
+ %w[
66
+ callbacks
67
+ callbacks/*
68
+ setup/dsl
69
+ setup/config
70
+ status
71
+ schemas/config
72
+ schemas/consumer_group_topic
73
+ schemas/consumer_group
74
+ ].each { |path| require_all File.join(Karafka.core_root, path + '.rb') }
75
+
76
+ Karafka::Loader.load!(Karafka.core_root)
77
+ Kafka::Consumer.prepend(Karafka::Patches::RubyKafka)
78
+ Dry::Configurable::Config.prepend(Karafka::Patches::DryConfigurable)