karafka-core 2.0.11 → 2.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5593ddb70f6e2cf57e058e2d8688dc55121ac02b9d6882358979edceff41dd87
4
- data.tar.gz: f2d5546158923107a84934711c567e4beb0a8e3bfa8b7697505eb94b70d90a9f
3
+ metadata.gz: 1896383dc8b2e0c161c30a66e3f95b91a83bd14b23f71f219a7aa58d3935410d
4
+ data.tar.gz: 7aff174b4151e3553767e39c2bcaa8227319e663c3d30ddcae0b3e3c8bca387c
5
5
  SHA512:
6
- metadata.gz: aaa78148833a7eda544fb5c03eb1f226422a439d27d08e8d431070ac944234b00d884fb9056e80f9327b461cc8dd80d44a782734655706a1a4841c4aa4b5f8c7
7
- data.tar.gz: '008ddf1bb91fb5b237d531337eb216d0870dbb39dd2cfe646b6dac07046a2b14891be02efb3957e1f8dc9742eae5586eeb20a21b39380d0f445a58124f6599ae'
6
+ metadata.gz: 64dd16a56f9ddc8e56e0c7fb7451df7b4e3d7b5d03c89d6a6c9f748d820b1203dfd436e1246fb596988d2a4757fc2bbca60252a37760bf04cbde72c63f5d0e62
7
+ data.tar.gz: ce8eb5da3c9ba4c765aa38ef3e91dd0b21809ca7f7e5833a7015ad434d5dd264af340fa7af509b0b7a1e3091e35d773e33ea620c7f79cb6acca403ed4622d733
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Karafka core changelog
2
2
 
3
+ ## 2.0.12 (2023-02-23)
4
+ - Introduce ability to tag certain objects by including the `Karafka::Core::Taggable` module.
5
+
3
6
  ## 2.0.11 (2023-02-12)
4
7
  - Set minimum `karafka-rdkafka` on `0.12.1`.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-core (2.0.11)
4
+ karafka-core (2.0.12)
5
5
  concurrent-ruby (>= 1.1)
6
6
  karafka-rdkafka (>= 0.12.1)
7
7
 
data/README.md CHANGED
@@ -6,11 +6,12 @@
6
6
 
7
7
  Karafka-Core contains toolset of small support modules used throughout the [Karafka](https://github.com/karafka/karafka/) ecosystem.
8
8
 
9
- It includes
9
+ It includes:
10
10
 
11
11
  - `Karafka::Core::Monitoring` - default instrumentation and abstraction that allows to use either itself, `dry-monitor` or `ActiveSupport::Notifications`.
12
12
  - `Karafka::Core::Configurable` - configuration engine inspired by `dry-config` with similar but simplified API.
13
13
  - `Karafka::Core::Contractable` - contracts inspired by `dry-validation` but with simplified API.
14
+ - `Karafka::Core::Taggable` - adds ability to attach `#tags` to objects for extra labeling.
14
15
 
15
16
  ## Note on contributions
16
17
 
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Core
5
+ module Taggable
6
+ # This allows us to collect tags about given object. We attach name to each tag, because we
7
+ # may want to replace given tag with a different one and we need to have a reference of
8
+ # what we want to replace
9
+ class Tags
10
+ # Creates new tags accumulator
11
+ def initialize
12
+ @accu = {}
13
+ end
14
+
15
+ # Adds a tag with a given name to tags
16
+ # @param name [Symbol] name we want to use for a given tag
17
+ # @param tag [#to_s] any object that can be converted into a string via `#to_s`
18
+ def add(name, tag)
19
+ @accu[name] = tag.to_s
20
+ end
21
+
22
+ # Removes all the tags
23
+ def clear
24
+ @accu.clear
25
+ end
26
+
27
+ # Removes a tag with a given name
28
+ # @param name [Symbol] name of the tag
29
+ def delete(name)
30
+ @accu.delete(name)
31
+ end
32
+
33
+ # @return [Array<String>] all unique tags registered
34
+ def to_a
35
+ @accu.values.tap(&:uniq!)
36
+ end
37
+
38
+ # @param _args [Object] anything that the standard `to_json` accepts
39
+ # @return [String] json representation of tags
40
+ def to_json(*_args)
41
+ to_a.to_json
42
+ end
43
+
44
+ # @param _args [Object] anything that the standard `as_json` accepts
45
+ # @return [Array<String>] array that can be converted to json
46
+ def as_json(*_args)
47
+ to_a
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Karafka
4
+ module Core
5
+ # Namespace related to extension allowing to attach tags to any object.
6
+ # It can be used to assign tags in runtime to objects and use those tags in metrics, reporting
7
+ # and other places.
8
+ #
9
+ # Tags will be converted to strings when they are added
10
+ module Taggable
11
+ # @return [::Karafka::Core::Taggable::Tags] tags object
12
+ def tags
13
+ @tags ||= Taggable::Tags.new
14
+ end
15
+ end
16
+ end
17
+ end
@@ -4,6 +4,6 @@ module Karafka
4
4
  module Core
5
5
  # Current Karafka::Core version
6
6
  # We follow the versioning schema of given Karafka version
7
- VERSION = '2.0.11'
7
+ VERSION = '2.0.12'
8
8
  end
9
9
  end
data/lib/karafka-core.rb CHANGED
@@ -30,6 +30,9 @@
30
30
  karafka/core/instrumentation
31
31
  karafka/core/instrumentation/callbacks_manager
32
32
 
33
+ karafka/core/taggable
34
+ karafka/core/taggable/tags
35
+
33
36
  karafka/core/patches/rdkafka/bindings
34
37
  ].each { |dependency| require dependency }
35
38
 
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- �,�9[��V""o�Qy T(j+�Q�lҙ�GGPK�� �'���nW:�jLuT?�rs��n ��5Csgu�&[9��;�9x�ŀ��+e.$�=dX���߯�u�;�+��Z�Bn.�܁Ԋ���B�&'��>%H}MH|����n�8���r ���ܖ�;^����i�����3dQ?c�}�1,�!����B�L����
2
- ��q�^���X痹F 5���Q֘V�hCތ���Lw��o�~
1
+ �v���]z��,��"a����ٙӬj�������O���!���̀��ͽ~%��J*d��#�Zq��{Ÿ 0lm�=��G-~־��[38��H�%t����� ��;�2���%il�K������J�\�ac�R2E+,��얠t�{Y�"hYꩯPL}tQ��ܵ„�� ��$�e�?<蹫m|�,��);�s �B��3��jq��z ��7JeXͣ�wo��p������@�D]۫���כj*�+jj�:�Q$�����v�yh��_9N��np ��д�����*�Y���=��\��l<*�?�Qx1A)0���A��Qq&�_EEj6�y$��p�ט.̔��}]26E���l��sVk,�WR
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qf04B9ceLUaC4fPVEz10FyobjaFoY4i32xRto3XnrzeAgfEe4swLq8bQsR3w/EF3
36
36
  MGU0FeSV2Yj7Xc2x/7BzLK8xQn5l7Yy75iPF+KP3vVmDHnNl
37
37
  -----END CERTIFICATE-----
38
- date: 2023-02-12 00:00:00.000000000 Z
38
+ date: 2023-02-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: concurrent-ruby
@@ -111,6 +111,8 @@ files:
111
111
  - lib/karafka/core/monitoring/notifications.rb
112
112
  - lib/karafka/core/monitoring/statistics_decorator.rb
113
113
  - lib/karafka/core/patches/rdkafka/bindings.rb
114
+ - lib/karafka/core/taggable.rb
115
+ - lib/karafka/core/taggable/tags.rb
114
116
  - lib/karafka/core/version.rb
115
117
  - log/.gitkeep
116
118
  homepage: https://karafka.io
metadata.gz.sig CHANGED
@@ -1,3 +1 @@
1
- -<�BE�"���&��9l��qbQ3[ ]AyJ4�|��f�����Ԍ�D �@� �� ���A*����=BVW��:�;��~�������$
2
- G��Cġv�B)�c�}��b� M�TA�:��~�����g�'�!
3
- ��9�B�"�P�1l�K,~����:l�53��fxx-M��9���+s�JOu@T�3't�pC�ΣSl&��i�}>{��R�)��]����St�4��!t��`As�i�?�|4�M{�<}}*?9^�f�Bm�ڶ�n�+�,1˃;�(h��~�3���<��f����c��t�v�C�i3�"�2�e�O�����4�H+���\ ��ъxWC�G��F���E?��u թ�
1
+ _�r`���:jf�Ϋ͂���Q�����*�������>���S���K�H>�PU�75���`t��T}����pHaK.>�2���n�6H��E�AJ�1�(t�Z�Xv?8�?id���;��C�v[M+�-dD����E�ۜ[id���G��g7\ ys��p7֧=�Oq,�l�l|Y��??Q``�Z����CRvU8ȃc2����V^Zkͥn.��b��g�\��b��%j�R�`�2O�x!