yes-core 2.6.1 → 2.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3628c3ea30a5599fa97c6533fd10d2214a0d5da009760b265fd0c11f8490349f
4
- data.tar.gz: b223d9f7ba3ba16cc2f4d267aabfca2a2c5f6aa6335a3c4388a8f98edc5978dd
3
+ metadata.gz: 533a9586de144c8b2a48bb212fc5bd9aaf601649d17493c9900c61e3ef5a2bba
4
+ data.tar.gz: 5db80562bbbda0ae1b89f316eeff38d775af52d2a069b3eabf859ff096354c65
5
5
  SHA512:
6
- metadata.gz: d676304cb10bdc7714ce0b3f4cd45bbcbf85242bd9ce75f13a1ef3683ed042e6849378f007ccaedc448af1cbf4a49b4b2e770c5606474c7e7dd052d59cd9077b
7
- data.tar.gz: a27b098783deeee35962fa5694f4fdaff7fd26a58d58b0a66bf6f799ca0d8ad1d0c79da259e266aec823abe450cdcde3942821e8fa8f3d6caece61115779eadd
6
+ metadata.gz: 06aeaf2d330a0af42aee1cab4bb66091cd641f64a6ee656458efd5f28a9383ea6f7d4ecea7ff63b5878857c78aa777c5c52bcf4ac2e0275efaa7344a5037dc9d
7
+ data.tar.gz: 3790c827bde9187ff82a7d69d3aa4557f588eb813132f6e942bc912f32b14a4cb08bfc9f29e8783455d709cec06ec1f5843c3504b7cc18ab35f09598e8f305a9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.7.0] - 2026-10-29
4
+ - See root CHANGELOG.md for details.
5
+
3
6
  ## [2.6.1] - 2026-10-28
4
7
  - See root CHANGELOG.md for details.
5
8
 
@@ -23,23 +23,47 @@ module Yes
23
23
  # @param origin [String] Origin of the command
24
24
  # @param notifier_options [Hash] Options for command notifier
25
25
  # @param batch_id [String] Batch ID
26
+ # @param extra_notifier_classes [Array<Class>] Notifier classes to run for this call only, in addition
27
+ # to the configured +command_notifier_classes+. They also run when commands are processed inline.
26
28
  # @return [void]
29
+ # @raise [ArgumentError] if an extra notifier class is anonymous or cannot be found again by its name
27
30
  def call(
28
31
  command_or_commands,
29
32
  origin: nil,
30
33
  notifier_options: {},
31
- batch_id: nil
34
+ batch_id: nil,
35
+ extra_notifier_classes: []
32
36
  )
37
+ ensure_notifier_classes_resolvable!(extra_notifier_classes)
38
+
33
39
  origin ||= Utils::CallerUtils.origin_from_caller(caller_locations(1..1).first)
34
40
 
35
41
  perform_method = perform_inline ? :perform_now : :perform_later
36
42
  self.class.current_span&.add_attributes({ perform_method: perform_method.to_s, origin: }.stringify_keys)
37
43
 
38
- command_processor.public_send(
39
- perform_method, origin, command_or_commands, notifier_options, batch_id, perform_inline
40
- )
44
+ # The extra argument is only passed when needed: during a rolling deploy an older worker runs jobs
45
+ # enqueued by this code, and a custom processor may still have the 5-argument signature.
46
+ # Only class names are passed, as the processor is an ActiveJob and its arguments must serialize.
47
+ processor_args = [origin, command_or_commands, notifier_options, batch_id, perform_inline]
48
+ processor_args << extra_notifier_classes.map(&:name) if extra_notifier_classes.any?
49
+
50
+ command_processor.public_send(perform_method, *processor_args)
41
51
  end
42
52
  otl_trackable :call, Yes::Core::OpenTelemetry::OtlSpan::OtlData.new(span_name: 'Command Bus Schedule')
53
+
54
+ private
55
+
56
+ # The processor finds the classes again by name, so fail here instead of inside the enqueued job.
57
+ # @param notifier_classes [Array<Class>] the per-call notifier classes
58
+ # @return [void]
59
+ # @raise [ArgumentError] if a class is anonymous or its name does not resolve to the same class
60
+ def ensure_notifier_classes_resolvable!(notifier_classes)
61
+ notifier_classes.each do |notifier_class|
62
+ next if notifier_class.name&.safe_constantize == notifier_class
63
+
64
+ raise ArgumentError, "extra_notifier_classes must be named, constantizable classes: #{notifier_class.inspect}"
65
+ end
66
+ end
43
67
  end
44
68
  end
45
69
  end
@@ -22,10 +22,16 @@ module Yes
22
22
  # @param command_or_commands [Command, Array<Command>] the command or commands to process
23
23
  # @param notifier_options [Hash] options to pass to the command notifier
24
24
  # @param custom_batch_id [String] Custom batch ID
25
+ # @param inline [Boolean] whether the commands are processed inline, which skips the configured notifiers
26
+ # @param extra_notifier_classes [Array<String>] names of notifier classes to run for this call only, in
27
+ # addition to the configured ones; they run also when inline
25
28
  # @return [Array<Response>] the responses from the performed commands
26
29
  # @raise [UnregisteredCommand] if any command lacks a handler
27
- def perform(origin, command_or_commands, notifier_options, custom_batch_id = nil, inline = false)
28
- setup(notifier_options, custom_batch_id, inline)
30
+ def perform(
31
+ origin, command_or_commands, notifier_options, custom_batch_id = nil, inline = false,
32
+ extra_notifier_classes = []
33
+ )
34
+ setup(notifier_options, custom_batch_id, inline, extra_notifier_classes)
29
35
  singleton_class.current_span&.add_event('Command Processor Setup Done')
30
36
 
31
37
  commands = [*command_or_commands]
@@ -53,17 +59,19 @@ module Yes
53
59
 
54
60
  private
55
61
 
56
- # Instantiates the command notifier from the config, using the given options.
57
- # @param notifier_options [Hash] the options to pass to the command notifier
62
+ # Instantiates the command notifiers from the config and the per-call extra ones, using the given options.
63
+ # @param notifier_options [Hash] the options to pass to the command notifiers
58
64
  # @param custom_batch_id [String] Custom batch ID
59
65
  # @param inline [Boolean] whether to process the commands inline
66
+ # @param extra_notifier_classes [Array<String>] names of the per-call notifier classes
60
67
  # @return [void]
61
- def setup(notifier_options, custom_batch_id, inline = false)
68
+ def setup(notifier_options, custom_batch_id, inline = false, extra_notifier_classes = [])
62
69
  @command_notifiers = [] if inline
63
70
 
64
71
  @command_notifiers ||= Yes::Core.configuration.command_notifier_classes&.map do |notifier_class|
65
72
  notifier_class.new(notifier_options)
66
73
  end || []
74
+ @command_notifiers += extra_notifier_classes.map { _1.constantize.new(notifier_options) }
67
75
  @custom_batch_id = custom_batch_id
68
76
  end
69
77
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yes
4
4
  module Core
5
- VERSION = '2.6.1'
5
+ VERSION = '2.7.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yes-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Ritsche