rimless 2.0.0 → 2.2.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/.github/workflows/release.yml +1 -1
- data/.github/workflows/test.yml +1 -1
- data/.rubocop.yml +5 -35
- data/Appraisals +5 -0
- data/CHANGELOG.md +10 -0
- data/Envfile +1 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +6 -6
- data/doc/kafka-playground/README.md +2 -2
- data/gemfiles/rails_7.1.gemfile +1 -1
- data/gemfiles/rails_7.2.gemfile +1 -1
- data/gemfiles/rails_8.0.gemfile +1 -1
- data/gemfiles/rails_8.1.gemfile +24 -0
- data/lib/rimless/compatibility/karafka_1_4.rb +0 -4
- data/lib/rimless/configuration.rb +41 -3
- data/lib/rimless/configuration_handling.rb +0 -3
- data/lib/rimless/consumer.rb +0 -8
- data/lib/rimless/dependencies.rb +0 -7
- data/lib/rimless/kafka_helpers.rb +0 -13
- data/lib/rimless/karafka/avro_deserializer.rb +2 -2
- data/lib/rimless/rspec/helpers.rb +0 -7
- data/lib/rimless/rspec/matchers.rb +0 -10
- data/lib/rimless/rspec.rb +1 -4
- data/lib/rimless/version.rb +1 -1
- data/lib/rimless.rb +2 -1
- data/rimless.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1b5957c80f5acbd1e6325410fa95f4765bfee153d509781074b9a680047c342
|
|
4
|
+
data.tar.gz: f19fe3dd85d3b8b4aa050fefdb7f73d764c5223be72a8db6adce7862635e2446
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4aa33a161c9f008523781c426aea9943a7295bd4bff73049edcbcdae8b4a9bc7eb9c3c6b0e58ebd1792bf8c4b5d6cba35ad886b716532ef917a92d2f599cd328
|
|
7
|
+
data.tar.gz: 837b9ee7470ab9a55fc1cb452558cfce631e530986f3bb7a7772ec381dabf8f423bce029f7bcdb026b921f4414465791da389fff8d2a832b4b75f702670c5dbe
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://potpourri.hausgold.de/config/rubocop.yml
|
|
3
|
+
- https://potpourri.hausgold.de/config/rubocop-gem.yml
|
|
4
|
+
|
|
1
5
|
plugins:
|
|
2
6
|
- rubocop-rspec
|
|
3
7
|
- rubocop-rails
|
|
@@ -5,15 +9,12 @@ plugins:
|
|
|
5
9
|
Rails:
|
|
6
10
|
Enabled: true
|
|
7
11
|
|
|
8
|
-
Style/Documentation:
|
|
9
|
-
Enabled: true
|
|
10
|
-
|
|
11
12
|
AllCops:
|
|
12
13
|
NewCops: enable
|
|
13
14
|
SuggestExtensions: false
|
|
14
15
|
DisplayCopNames: true
|
|
15
16
|
TargetRubyVersion: 3.2
|
|
16
|
-
TargetRailsVersion:
|
|
17
|
+
TargetRailsVersion: 7.1
|
|
17
18
|
Exclude:
|
|
18
19
|
- bin/**/*
|
|
19
20
|
- vendor/**/*
|
|
@@ -21,43 +22,12 @@ AllCops:
|
|
|
21
22
|
- gemfiles/**/*
|
|
22
23
|
- doc/kafka-playground/**/*
|
|
23
24
|
|
|
24
|
-
Metrics/BlockLength:
|
|
25
|
-
Exclude:
|
|
26
|
-
- Rakefile
|
|
27
|
-
- '*.gemspec'
|
|
28
|
-
- spec/**/*.rb
|
|
29
|
-
- '**/*.rake'
|
|
30
|
-
- doc/**/*.rb
|
|
31
|
-
|
|
32
|
-
# MFA is not yet enabled for our gems yet.
|
|
33
|
-
Gemspec/RequireMFA:
|
|
34
|
-
Enabled: false
|
|
35
|
-
|
|
36
|
-
# We stay with the original Ruby Style Guide recommendation.
|
|
37
|
-
Layout/LineLength:
|
|
38
|
-
Max: 80
|
|
39
|
-
|
|
40
|
-
# Document all the things.
|
|
41
|
-
Style/DocumentationMethod:
|
|
42
|
-
Enabled: true
|
|
43
|
-
RequireForNonPublicMethods: true
|
|
44
|
-
|
|
45
25
|
# It's a deliberate idiom in RSpec.
|
|
46
26
|
# See: https://github.com/bbatsov/rubocop/issues/4222
|
|
47
27
|
Lint/AmbiguousBlockAssociation:
|
|
48
28
|
Exclude:
|
|
49
29
|
- "spec/**/*"
|
|
50
30
|
|
|
51
|
-
# Because +expect_any_instance_of().to have_received()+ is not
|
|
52
|
-
# supported with the +with(hash_including)+ matchers
|
|
53
|
-
RSpec/MessageSpies:
|
|
54
|
-
EnforcedStyle: receive
|
|
55
|
-
|
|
56
|
-
# Because nesting makes sense here to group the feature tests
|
|
57
|
-
# more effective. This increases maintainability.
|
|
58
|
-
RSpec/NestedGroups:
|
|
59
|
-
Max: 4
|
|
60
|
-
|
|
61
31
|
# Disable regular Rails spec paths.
|
|
62
32
|
Rails/FilePath:
|
|
63
33
|
Enabled: false
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
* TODO: Replace this bullet point with an actual description of a change.
|
|
4
4
|
|
|
5
|
+
### 2.2.0 (19 December 2025)
|
|
6
|
+
|
|
7
|
+
* Migrated to a shared Rubocop configuration for HAUSGOLD gems ([#62](https://github.com/hausgold/rimless/pull/62))
|
|
8
|
+
|
|
9
|
+
### 2.1.0 (23 October 2025)
|
|
10
|
+
|
|
11
|
+
* Added support for Rails 8.1 ([#60](https://github.com/hausgold/rimless/pull/60))
|
|
12
|
+
* Switched from `ActiveSupport::Configurable` to a custom implementation based
|
|
13
|
+
on `ActiveSupport::OrderedOptions` ([#61](https://github.com/hausgold/rimless/pull/61))
|
|
14
|
+
|
|
5
15
|
### 2.0.0 (28 June 2025)
|
|
6
16
|
|
|
7
17
|
* Corrected some RuboCop glitches ([#58](https://github.com/hausgold/rimless/pull/58))
|
data/Envfile
CHANGED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -132,7 +132,7 @@ Registry. The subject naming convention is mostly the same as the Apache Kafka
|
|
|
132
132
|
Topic convention, except the allowed characters. [Apache
|
|
133
133
|
Avro](https://avro.apache.org/docs/1.8.2/spec.html#namespace) just allows
|
|
134
134
|
`[A-Za-z0-9_]` and no numbers on the first char. The application environment
|
|
135
|
-
prefix allows the usage of the very same Schema Registry instance for
|
|
135
|
+
prefix allows the usage of the very same Schema Registry instance for multiple
|
|
136
136
|
environments and the application name just reflects the schema origin.
|
|
137
137
|
Convention rules:
|
|
138
138
|
|
|
@@ -167,7 +167,7 @@ Each schema template MUST end with the `.avsc.erb` extension to be picked up,
|
|
|
167
167
|
even in recursive directory structures. You can make use of the ERB templating
|
|
168
168
|
or not, but rimless just looks for these templates. When it comes to
|
|
169
169
|
structuring the Avro Schemas it is important that the file path reflects the
|
|
170
|
-
|
|
170
|
+
embedded schema namespace correctly. So when `$(pwd)/config/avro_schemas` is our
|
|
171
171
|
schema namespace root, then the `production.identity_api.user_v1` schema
|
|
172
172
|
converts to the
|
|
173
173
|
`$(pwd)/config/avro_schemas/compiled/production/identity_api/user_v1.avsc`
|
|
@@ -456,7 +456,7 @@ were the user (eg. a frontend client) just can add whatever comes to his mind
|
|
|
456
456
|
for later processing. Its not searchable, its never touched by the backend, but
|
|
457
457
|
its present.
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
That's a case we're experienced and kind of solved on the rimless gem. You can
|
|
460
460
|
make use of the `Rimless.avro_schemaless_h` method to [sparsify the data
|
|
461
461
|
recursively](https://github.com/simplymeasured/sparsify). Say you have the
|
|
462
462
|
following metadata hash:
|
|
@@ -476,7 +476,7 @@ metadata = {
|
|
|
476
476
|
|
|
477
477
|
It's messy, by design. From the Apache Avro perspective you just can define a
|
|
478
478
|
map. The map keys are assumed to be strings - and the most hitting value data
|
|
479
|
-
type is a string, too.
|
|
479
|
+
type is a string, too. That's where hash sparsification comes in. The resulting
|
|
480
480
|
metadata hash looks like this and can be encoded by Apache Avro:
|
|
481
481
|
|
|
482
482
|
```ruby
|
|
@@ -500,10 +500,10 @@ Avro schema to be a string. Choice is yours.
|
|
|
500
500
|
### Writing tests for your messages
|
|
501
501
|
|
|
502
502
|
Producing messages is a bliss with the rimless gem, but producing code needs to
|
|
503
|
-
be tested as well.
|
|
503
|
+
be tested as well. That's why the gem ships some RSpec helpers and matchers for
|
|
504
504
|
this purpose. A common situation is also handled by the RSpec extension: on the
|
|
505
505
|
test environment (eg. a continuous integration service) its not likely to have
|
|
506
|
-
a Apache Kafka/Confluent Schema Registry cluster available.
|
|
506
|
+
a Apache Kafka/Confluent Schema Registry cluster available. That's why actual
|
|
507
507
|
calls to Kafka/Schema Registry are mocked away.
|
|
508
508
|
|
|
509
509
|
First of all, just add `require 'rimless/rspec'` to your `spec_helper.rb` or
|
|
@@ -73,7 +73,7 @@ the creation of the `/etc/mdns.allow` file.
|
|
|
73
73
|
|
|
74
74
|
## What's in the box
|
|
75
75
|
|
|
76
|
-
After the installation and
|
|
76
|
+
After the installation and boot-up processes are finished you should have a
|
|
77
77
|
working Apache Kafka setup which includes the following:
|
|
78
78
|
|
|
79
79
|
* A single node [Apache Kafka](https://kafka.apache.org/) (without Zookeeper,
|
|
@@ -108,7 +108,7 @@ Metadata for all topics (from broker 1001: kafka.playground.local:9092/1001):
|
|
|
108
108
|
topic "test" with 1 partitions:
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
Now start a second
|
|
111
|
+
Now start a second terminal playground container with `$ make shell` and run:
|
|
112
112
|
|
|
113
113
|
```shell
|
|
114
114
|
# Terminal B
|
data/gemfiles/rails_7.1.gemfile
CHANGED
data/gemfiles/rails_7.2.gemfile
CHANGED
data/gemfiles/rails_8.0.gemfile
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal", "~> 2.4"
|
|
6
|
+
gem "bundler", "~> 2.6"
|
|
7
|
+
gem "countless", "~> 2.2"
|
|
8
|
+
gem "factory_bot", "~> 6.2"
|
|
9
|
+
gem "guard-rspec", "~> 4.7"
|
|
10
|
+
gem "railties", "~> 8.1.0"
|
|
11
|
+
gem "rake", "~> 13.0"
|
|
12
|
+
gem "redcarpet", "~> 3.5"
|
|
13
|
+
gem "rspec", "~> 3.12"
|
|
14
|
+
gem "rubocop"
|
|
15
|
+
gem "rubocop-rails"
|
|
16
|
+
gem "rubocop-rspec"
|
|
17
|
+
gem "simplecov", ">= 0.22"
|
|
18
|
+
gem "timecop", ">= 0.9.6"
|
|
19
|
+
gem "vcr", "~> 6.0"
|
|
20
|
+
gem "yard", ">= 0.9.28"
|
|
21
|
+
gem "yard-activesupport-concern", ">= 0.0.1"
|
|
22
|
+
gem "activesupport", "~> 8.1.0"
|
|
23
|
+
|
|
24
|
+
gemspec path: "../"
|
|
@@ -17,9 +17,6 @@ module Karafka
|
|
|
17
17
|
# This method is a wrapper to way Thor defines its commands.
|
|
18
18
|
#
|
|
19
19
|
# @param cli_class [Karafka::Cli] the class to bind to
|
|
20
|
-
#
|
|
21
|
-
# rubocop:disable Metrics/MethodLength -- because of the
|
|
22
|
-
# monkey-patching logic
|
|
23
20
|
def bind_to(cli_class)
|
|
24
21
|
@aliases ||= []
|
|
25
22
|
@options ||= []
|
|
@@ -49,7 +46,6 @@ module Karafka
|
|
|
49
46
|
cli_class.map cmd_alias => name.to_s
|
|
50
47
|
end
|
|
51
48
|
end
|
|
52
|
-
# rubocop:enable Metrics/MethodLength
|
|
53
49
|
end
|
|
54
50
|
end
|
|
55
51
|
end
|
|
@@ -2,8 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
module Rimless
|
|
4
4
|
# The configuration for the rimless gem.
|
|
5
|
-
class Configuration
|
|
6
|
-
|
|
5
|
+
class Configuration < ActiveSupport::OrderedOptions
|
|
6
|
+
# Track our configurations settings (+Symbol+ keys) and their defaults as
|
|
7
|
+
# lazy-loaded +Proc+'s values
|
|
8
|
+
class_attribute :defaults,
|
|
9
|
+
instance_reader: true,
|
|
10
|
+
instance_writer: false,
|
|
11
|
+
instance_predicate: false,
|
|
12
|
+
default: {}
|
|
13
|
+
|
|
14
|
+
# Create a new +Configuration+ instance with all settings populated with
|
|
15
|
+
# their respective defaults.
|
|
16
|
+
#
|
|
17
|
+
# @param args [Hash{Symbol => Mixed}] additional settings which
|
|
18
|
+
# overwrite the defaults
|
|
19
|
+
# @return [Configuration] the new configuration instance
|
|
20
|
+
def initialize(**args)
|
|
21
|
+
super()
|
|
22
|
+
defaults.each { |key, default| self[key] = instance_exec(&default) }
|
|
23
|
+
merge!(**args)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A simple DSL method to define new configuration accessors/settings with
|
|
27
|
+
# their defaults. The defaults can be retrieved with
|
|
28
|
+
# +Configuration.defaults+ or +Configuration.new.defaults+.
|
|
29
|
+
#
|
|
30
|
+
# @param name [Symbol, String] the name of the configuration
|
|
31
|
+
# accessor/setting
|
|
32
|
+
# @param default [Mixed, nil] a non-lazy-loaded static value, serving as a
|
|
33
|
+
# default value for the setting
|
|
34
|
+
# @param block [Proc] when given, the default value will be lazy-loaded
|
|
35
|
+
# (result of the Proc)
|
|
36
|
+
def self.config_accessor(name, default = nil, &block)
|
|
37
|
+
# Save the given configuration accessor default value
|
|
38
|
+
defaults[name.to_sym] = block || -> { default }
|
|
39
|
+
|
|
40
|
+
# Compile reader/writer methods so we don't have to go through
|
|
41
|
+
# +ActiveSupport::OrderedOptions#method_missing+.
|
|
42
|
+
define_method(name) { self[name] }
|
|
43
|
+
define_method("#{name}=") { |value| self[name] = value }
|
|
44
|
+
end
|
|
7
45
|
|
|
8
46
|
# Used to identity this client on the user agent header
|
|
9
47
|
config_accessor(:app_name) { Rimless.local_app_name }
|
|
@@ -67,7 +105,7 @@ module Rimless
|
|
|
67
105
|
#
|
|
68
106
|
# @param val [String, Symbol] the new job queue name
|
|
69
107
|
def consumer_job_queue=(val)
|
|
70
|
-
|
|
108
|
+
self[:consumer_job_queue] = val.to_sym
|
|
71
109
|
# Refresh the consumer job queue
|
|
72
110
|
Rimless::ConsumerJob.sidekiq_options(
|
|
73
111
|
queue: Rimless.configuration.consumer_job_queue
|
|
@@ -4,8 +4,6 @@ module Rimless
|
|
|
4
4
|
# The top-level configuration handling.
|
|
5
5
|
#
|
|
6
6
|
# rubocop:disable Style/ClassVars -- because we split module code
|
|
7
|
-
# rubocop:disable Metrics/BlockLength -- because this is how an
|
|
8
|
-
# +ActiveSupport::Concern+ looks like
|
|
9
7
|
module ConfigurationHandling
|
|
10
8
|
extend ActiveSupport::Concern
|
|
11
9
|
|
|
@@ -81,5 +79,4 @@ module Rimless
|
|
|
81
79
|
end
|
|
82
80
|
end
|
|
83
81
|
# rubocop:enable Style/ClassVars
|
|
84
|
-
# rubocop:enable Metrics/BlockLength
|
|
85
82
|
end
|
data/lib/rimless/consumer.rb
CHANGED
|
@@ -76,9 +76,6 @@ module Rimless
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
# Configure the pure basics on the Karafka application.
|
|
79
|
-
#
|
|
80
|
-
# rubocop:disable Metrics/MethodLength -- because of the various settings
|
|
81
|
-
# rubocop:disable Metrics/AbcSize -- ditto
|
|
82
79
|
def initialize_karafka!
|
|
83
80
|
setup do |config|
|
|
84
81
|
mapper = Rimless::Karafka::PassthroughMapper.new
|
|
@@ -93,8 +90,6 @@ module Rimless
|
|
|
93
90
|
config.shutdown_timeout = 10
|
|
94
91
|
end
|
|
95
92
|
end
|
|
96
|
-
# rubocop:enable Metrics/MethodLength
|
|
97
|
-
# rubocop:enable Metrics/AbcSize
|
|
98
93
|
|
|
99
94
|
# When we run in development mode, we want to write the logs
|
|
100
95
|
# to file and to stdout.
|
|
@@ -147,8 +142,6 @@ module Rimless
|
|
|
147
142
|
#
|
|
148
143
|
# @param topics [Hash{Hash => Class}] the topic to consumer mapping
|
|
149
144
|
# @yield the given block on the routing table
|
|
150
|
-
#
|
|
151
|
-
# rubocop:disable Metrics/MethodLength -- because of the Karafka DSL
|
|
152
145
|
def topics(topics = [], &block)
|
|
153
146
|
consumer_groups.draw do
|
|
154
147
|
consumer_group(Rimless.configuration.client_id) do
|
|
@@ -168,7 +161,6 @@ module Rimless
|
|
|
168
161
|
|
|
169
162
|
self
|
|
170
163
|
end
|
|
171
|
-
# rubocop:enable Metrics/MethodLength
|
|
172
164
|
|
|
173
165
|
# Build the conventional Apache Kafka topic names from the given parts.
|
|
174
166
|
# This allows various forms like single strings/symbols and a hash in the
|
data/lib/rimless/dependencies.rb
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
module Rimless
|
|
4
4
|
# The top-level dependencies helpers.
|
|
5
|
-
#
|
|
6
|
-
# rubocop:disable Metrics/BlockLength -- because its an Active Support
|
|
7
|
-
# concern
|
|
8
5
|
module Dependencies
|
|
9
6
|
extend ActiveSupport::Concern
|
|
10
7
|
|
|
@@ -18,8 +15,6 @@ module Rimless
|
|
|
18
15
|
end
|
|
19
16
|
|
|
20
17
|
# Set sensible defaults for the +WaterDrop+ gem.
|
|
21
|
-
#
|
|
22
|
-
# rubocop:disable Metrics/AbcSize -- because of the configuration mapping
|
|
23
18
|
def configure_waterdrop
|
|
24
19
|
# Skip WaterDrop configuration when no brokers/client id is available,
|
|
25
20
|
# because it will raise. Its fine to have none available for situations
|
|
@@ -46,7 +41,6 @@ module Rimless
|
|
|
46
41
|
config.kafka.required_acks = -1
|
|
47
42
|
end
|
|
48
43
|
end
|
|
49
|
-
# rubocop:enable Metrics/AbcSize
|
|
50
44
|
|
|
51
45
|
# Set sensible defaults for the +AvroTurf+ gem and (re)compile the Apache
|
|
52
46
|
# Avro schema templates (ERB), so the gem can handle them properly.
|
|
@@ -72,5 +66,4 @@ module Rimless
|
|
|
72
66
|
end
|
|
73
67
|
end
|
|
74
68
|
end
|
|
75
|
-
# rubocop:enable Metrics/BlockLength
|
|
76
69
|
end
|
|
@@ -5,8 +5,6 @@ module Rimless
|
|
|
5
5
|
module KafkaHelpers
|
|
6
6
|
extend ActiveSupport::Concern
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Metrics/BlockLength -- because its an Active Support
|
|
9
|
-
# concern
|
|
10
8
|
class_methods do
|
|
11
9
|
# Generate a common topic name for Apache Kafka while taking care of
|
|
12
10
|
# configured prefixes.
|
|
@@ -22,12 +20,6 @@ module Rimless
|
|
|
22
20
|
# Rimless.topic(name: 'test', app: :fancy_app)
|
|
23
21
|
# @example Full name - use as is
|
|
24
22
|
# Rimless.topic(full_name: 'my.custom.topic.name')
|
|
25
|
-
#
|
|
26
|
-
# rubocop:disable Metrics/MethodLength -- because of the usage
|
|
27
|
-
# flexibility
|
|
28
|
-
# rubocop:disable Metrics/AbcSize -- ditto
|
|
29
|
-
# rubocop:disable Metrics/CyclomaticComplexity -- ditto
|
|
30
|
-
# rubocop:disable Metrics/PerceivedComplexity -- ditto
|
|
31
23
|
def topic(*args)
|
|
32
24
|
opts = args.last
|
|
33
25
|
name = args.first if [String, Symbol].member?(args.first.class)
|
|
@@ -47,10 +39,6 @@ module Rimless
|
|
|
47
39
|
|
|
48
40
|
"#{Rimless.topic_prefix(app)}#{name}".tr('_', '-')
|
|
49
41
|
end
|
|
50
|
-
# rubocop:enable Metrics/MethodLength
|
|
51
|
-
# rubocop:enable Metrics/AbcSize
|
|
52
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
53
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
|
54
42
|
|
|
55
43
|
# Send a single message to Apache Kafka. The data is encoded according to
|
|
56
44
|
# the given Apache Avro schema. The destination Kafka topic may be a
|
|
@@ -112,6 +100,5 @@ module Rimless
|
|
|
112
100
|
WaterDrop::AsyncProducer.call(data, **args)
|
|
113
101
|
end
|
|
114
102
|
end
|
|
115
|
-
# rubocop:enable Metrics/BlockLength
|
|
116
103
|
end
|
|
117
104
|
end
|
|
@@ -14,9 +14,9 @@ module Rimless
|
|
|
14
14
|
return if params.raw_payload.nil?
|
|
15
15
|
|
|
16
16
|
# We use sparsed hashes inside of Apache Avro messages for schema-less
|
|
17
|
-
# blobs of data, such as loosely structured metadata blobs.
|
|
17
|
+
# blobs of data, such as loosely structured metadata blobs. That's a
|
|
18
18
|
# somewhat bad idea on strictly typed and defined messages, but their
|
|
19
|
-
#
|
|
19
|
+
# occurrence should be rare.
|
|
20
20
|
Rimless
|
|
21
21
|
.decode(params.raw_payload)
|
|
22
22
|
.then { |data| Sparsify(data, sparse_array: true) }
|
|
@@ -21,11 +21,6 @@ module Rimless
|
|
|
21
21
|
# @param topic [String, Hash{Symbol => Mixed}] the actual message
|
|
22
22
|
# topic (full as string, or parts via hash)
|
|
23
23
|
# @return [OpenStruct] the fake deserialized Kafka message
|
|
24
|
-
#
|
|
25
|
-
# rubocop:disable Metrics/MethodLength -- because of the various
|
|
26
|
-
# properties
|
|
27
|
-
# rubocop:disable Style/OpenStructUse -- because existing specs may rely
|
|
28
|
-
# on this data type
|
|
29
24
|
def kafka_message(topic: nil, headers: {}, **payload)
|
|
30
25
|
OpenStruct.new(
|
|
31
26
|
topic: Rimless.topic(topic),
|
|
@@ -40,8 +35,6 @@ module Rimless
|
|
|
40
35
|
deserialized: true
|
|
41
36
|
)
|
|
42
37
|
end
|
|
43
|
-
# rubocop:enable Metrics/MethodLength
|
|
44
|
-
# rubocop:enable Style/OpenStructUse
|
|
45
38
|
|
|
46
39
|
# Capture all Apache Kafka messages of the given block.
|
|
47
40
|
#
|
|
@@ -6,9 +6,6 @@ module Rimless
|
|
|
6
6
|
# A set of Rimless/RSpec matchers.
|
|
7
7
|
module Matchers
|
|
8
8
|
# The Apache Kafka message expectation.
|
|
9
|
-
#
|
|
10
|
-
# rubocop:disable Metrics/ClassLength -- because its almost RSpec API
|
|
11
|
-
# code
|
|
12
9
|
class HaveSentKafkaMessage < ::RSpec::Matchers::BuiltIn::BaseMatcher
|
|
13
10
|
include ::RSpec::Mocks::ExampleMethods
|
|
14
11
|
|
|
@@ -165,9 +162,6 @@ module Rimless
|
|
|
165
162
|
# Perform the result set checking of recorded message which were sent.
|
|
166
163
|
#
|
|
167
164
|
# @return [Boolean] the answer
|
|
168
|
-
#
|
|
169
|
-
# rubocop:disable Naming/PredicateMethod -- because this method performs
|
|
170
|
-
# an action, not a predicate check (bool is for error signaling)
|
|
171
165
|
def check
|
|
172
166
|
@matching, @unmatching = @messages.partition do |message|
|
|
173
167
|
schema_match?(message) && arguments_match?(message) &&
|
|
@@ -182,7 +176,6 @@ module Rimless
|
|
|
182
176
|
when :at_least then @expected_number <= @matching_count
|
|
183
177
|
end
|
|
184
178
|
end
|
|
185
|
-
# rubocop:enable Naming/PredicateMethod
|
|
186
179
|
|
|
187
180
|
# Check for the expected schema on the given message.
|
|
188
181
|
#
|
|
@@ -224,7 +217,6 @@ module Rimless
|
|
|
224
217
|
|
|
225
218
|
# Setup the +WaterDrop+ spies and record each sent message.
|
|
226
219
|
# because of the message decoding
|
|
227
|
-
# rubocop:disable Metrics/MethodLength -- ditto
|
|
228
220
|
def listen_to_messages
|
|
229
221
|
decode = proc do |encoded|
|
|
230
222
|
{ encoded_data: encoded, data: Rimless.avro.decode(encoded) }
|
|
@@ -240,7 +232,6 @@ module Rimless
|
|
|
240
232
|
nil
|
|
241
233
|
end
|
|
242
234
|
end
|
|
243
|
-
# rubocop:enable Metrics/MethodLength
|
|
244
235
|
|
|
245
236
|
# Serve the RSpec API and return the positive failure message.
|
|
246
237
|
#
|
|
@@ -293,7 +284,6 @@ module Rimless
|
|
|
293
284
|
result.join
|
|
294
285
|
end
|
|
295
286
|
end
|
|
296
|
-
# rubocop:enable Metrics/ClassLength
|
|
297
287
|
|
|
298
288
|
# Check for messages which were sent to Apache Kafka by the given block.
|
|
299
289
|
#
|
data/lib/rimless/rspec.rb
CHANGED
|
@@ -11,7 +11,7 @@ require 'karafka/testing/rspec/helpers'
|
|
|
11
11
|
# this dependency as runtime, just as development. Therefore we added it.
|
|
12
12
|
require 'avro_turf/test/fake_confluent_schema_registry_server'
|
|
13
13
|
|
|
14
|
-
# Add a monkey patch to add
|
|
14
|
+
# Add a monkey patch to add proper Sinatra 4.x support
|
|
15
15
|
class FakeConfluentSchemaRegistryServer
|
|
16
16
|
# Allow any host name on tests
|
|
17
17
|
set :host_authorization, { permitted_hosts: [] }
|
|
@@ -23,8 +23,6 @@ end
|
|
|
23
23
|
raise 'No RSPEC_CONFIGURER is defined, webmock is missing?' \
|
|
24
24
|
unless defined?(RSPEC_CONFIGURER)
|
|
25
25
|
|
|
26
|
-
# rubocop:disable Metrics/BlockLength -- because we have to configure RSpec
|
|
27
|
-
# properly
|
|
28
26
|
RSPEC_CONFIGURER.configure do |config|
|
|
29
27
|
config.include Rimless::RSpec::Helpers
|
|
30
28
|
config.include Rimless::RSpec::Matchers
|
|
@@ -83,4 +81,3 @@ RSPEC_CONFIGURER.configure do |config|
|
|
|
83
81
|
Rimless.consumer.initialize! if example.metadata[:type] == :consumer
|
|
84
82
|
end
|
|
85
83
|
end
|
|
86
|
-
# rubocop:enable Metrics/BlockLength
|
data/lib/rimless/version.rb
CHANGED
data/lib/rimless.rb
CHANGED
|
@@ -4,9 +4,10 @@ require 'zeitwerk'
|
|
|
4
4
|
require 'logger'
|
|
5
5
|
require 'active_support'
|
|
6
6
|
require 'active_support/concern'
|
|
7
|
-
require 'active_support/
|
|
7
|
+
require 'active_support/ordered_options'
|
|
8
8
|
require 'active_support/time'
|
|
9
9
|
require 'active_support/time_with_zone'
|
|
10
|
+
require 'active_support/core_ext/class/attribute'
|
|
10
11
|
require 'active_support/core_ext/object'
|
|
11
12
|
require 'active_support/core_ext/module'
|
|
12
13
|
require 'active_support/core_ext/hash'
|
data/rimless.gemspec
CHANGED
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
|
40
40
|
spec.add_dependency 'karafka', '~> 1.4', '< 1.4.15'
|
|
41
41
|
spec.add_dependency 'karafka-sidekiq-backend', '~> 1.4'
|
|
42
42
|
spec.add_dependency 'karafka-testing', '~> 1.4'
|
|
43
|
-
spec.add_dependency 'mutex_m', '
|
|
43
|
+
spec.add_dependency 'mutex_m', '>= 0.3'
|
|
44
44
|
spec.add_dependency 'retries', '>= 0.0.5'
|
|
45
45
|
spec.add_dependency 'sinatra', '>= 2.2'
|
|
46
46
|
spec.add_dependency 'sparsify', '~> 1.1'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rimless
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hermann Mayer
|
|
@@ -89,16 +89,16 @@ dependencies:
|
|
|
89
89
|
name: mutex_m
|
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
|
92
|
-
- - "
|
|
92
|
+
- - ">="
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: 0.3
|
|
94
|
+
version: '0.3'
|
|
95
95
|
type: :runtime
|
|
96
96
|
prerelease: false
|
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
|
99
|
-
- - "
|
|
99
|
+
- - ">="
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: 0.3
|
|
101
|
+
version: '0.3'
|
|
102
102
|
- !ruby/object:Gem::Dependency
|
|
103
103
|
name: retries
|
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -245,6 +245,7 @@ files:
|
|
|
245
245
|
- gemfiles/rails_7.1.gemfile
|
|
246
246
|
- gemfiles/rails_7.2.gemfile
|
|
247
247
|
- gemfiles/rails_8.0.gemfile
|
|
248
|
+
- gemfiles/rails_8.1.gemfile
|
|
248
249
|
- lib/rimless.rb
|
|
249
250
|
- lib/rimless/avro_helpers.rb
|
|
250
251
|
- lib/rimless/avro_utils.rb
|