lepus 0.2.1 → 0.2.2
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/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/gemfiles/Gemfile.rails-5.2.lock +1 -1
- data/gemfiles/Gemfile.rails-6.1.lock +1 -1
- data/gemfiles/Gemfile.rails-7.2.lock +1 -1
- data/gemfiles/Gemfile.rails-8.0.lock +1 -1
- data/lib/lepus/cli.rb +9 -1
- data/lib/lepus/supervisor.rb +3 -1
- data/lib/lepus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9eb1d12b4ce05f9c4e9070d7083b68417b7a41b7cdb2b1a99cad2931c9879fe
|
|
4
|
+
data.tar.gz: 1a6eafc5a47b48a228279e5ede1a06acfea053b04cf686e8984719633d60e66b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40432e83f566507da124995e9a60130e10dbf54cc499ad8d3a6598369c0b8d3d9b78ab28be9fa6ca82812951092e28baead30d15d8b83feb6eeed9c6a30ebe32
|
|
7
|
+
data.tar.gz: '08948dbc7e9a927e2d26787a81c1106c1afb392aed5373248c54a02909a96d8d21b7e9f8c42a90e3ac4bc6179bfe1e5cc0c77c483be7d4808293bc6c51259213'
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 0.2.2 - 2026-10-30
|
|
8
|
+
* Added: `lepus start --except A,B` (and `Supervisor.new(except:)`) runs every consumer but the ones listed
|
|
9
|
+
|
|
7
10
|
## 0.2.1 - 2026-10-30
|
|
8
11
|
* Added: `process_delivery.lepus` instrumentation around every consumed message, with consumer, exchange, routing key, redelivered flag and result
|
|
9
12
|
* Added: `consumer_error.lepus` instrumentation when `#perform` raises, before the message is rejected
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -567,6 +567,12 @@ bundle exec lepus start MyConsumer1 MyConsumer2 --debug
|
|
|
567
567
|
|
|
568
568
|
Each consumer will run in a separate process, and a supervisor will monitor them. If a consumer crashes, the supervisor will restart it.
|
|
569
569
|
|
|
570
|
+
To run every consumer except some, for example to move one to its own deployment, use `--except` with a comma-separated list:
|
|
571
|
+
|
|
572
|
+
```bash
|
|
573
|
+
bundle exec lepus start --except MyConsumer1,MyConsumer2
|
|
574
|
+
```
|
|
575
|
+
|
|
570
576
|
### Instrumentation and logging
|
|
571
577
|
|
|
572
578
|
Every consumed message emits a `process_delivery.lepus` event (`consumer`, `exchange`, `routing_key`, `redelivered`, `result`), and an exception raised by `#perform` emits `consumer_error.lepus` (with `error`) before the message is rejected. In Rails, `Lepus::LogSubscriber` logs both to `Lepus.logger`:
|
data/lib/lepus/cli.rb
CHANGED
|
@@ -10,6 +10,7 @@ module Lepus
|
|
|
10
10
|
method_option :logfile, type: :string, default: nil
|
|
11
11
|
method_option :pidfile, type: :string, default: nil
|
|
12
12
|
method_option :require_file, type: :string, aliases: "-r", default: nil
|
|
13
|
+
method_option :except, type: :array, default: nil, desc: "Consumers to leave out"
|
|
13
14
|
|
|
14
15
|
desc "start FirstConsumer SecondConsumer ... NthConsumer", "Run Consumer"
|
|
15
16
|
default_command :start
|
|
@@ -17,9 +18,10 @@ module Lepus
|
|
|
17
18
|
def start(*consumers)
|
|
18
19
|
opts = (@options || {}).transform_keys(&:to_sym)
|
|
19
20
|
|
|
20
|
-
if (list = consumers
|
|
21
|
+
if (list = consumer_names(consumers)).any?
|
|
21
22
|
opts[:consumers] = list
|
|
22
23
|
end
|
|
24
|
+
opts[:except] = consumer_names(opts[:except]) if opts[:except]
|
|
23
25
|
|
|
24
26
|
if (logfile = opts.delete(:logfile))
|
|
25
27
|
Lepus.logger = Logger.new(logfile)
|
|
@@ -78,5 +80,11 @@ module Lepus
|
|
|
78
80
|
MSG
|
|
79
81
|
end
|
|
80
82
|
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def consumer_names(names)
|
|
87
|
+
names.flat_map { |name| name.split(",") }.map(&:strip).reject(&:empty?).uniq.sort
|
|
88
|
+
end
|
|
81
89
|
end
|
|
82
90
|
end
|
data/lib/lepus/supervisor.rb
CHANGED
|
@@ -21,11 +21,13 @@ module Lepus
|
|
|
21
21
|
# @param pidfile [String] The path to the pidfile where the supervisor's PID will be stored. Default is "tmp/pids/lepus.pid".
|
|
22
22
|
# @param shutdown_timeout [Integer] The timeout in seconds to wait for child processes to terminate gracefully before forcing termination. Default is 5 seconds.
|
|
23
23
|
# @param consumers [Array<String, Class>] An optional list of consumer class names (as strings or constants) to be run by this supervisor. If not provided, all discovered consumer classes will be used.
|
|
24
|
+
# @param except [Array<String, Class>] An optional list of consumer class names (as strings or constants) to leave out.
|
|
24
25
|
def initialize(require_file: nil, pidfile: "tmp/pids/lepus.pid", shutdown_timeout: 5, **kwargs)
|
|
25
26
|
@pidfile_path = pidfile
|
|
26
27
|
@require_file = require_file
|
|
27
28
|
@shutdown_timeout = shutdown_timeout.to_i
|
|
28
29
|
@consumer_class_names = Array(kwargs[:consumers]).map(&:to_s) if kwargs.key?(:consumers)
|
|
30
|
+
@excluded_consumer_names = Array(kwargs[:except]).map(&:to_s)
|
|
29
31
|
|
|
30
32
|
@forks = {}
|
|
31
33
|
@pipes = {}
|
|
@@ -79,7 +81,7 @@ module Lepus
|
|
|
79
81
|
@consumer_class_names.map { |name| Lepus::Primitive::String.new(name).constantize }
|
|
80
82
|
else
|
|
81
83
|
Lepus::Consumer.descendants
|
|
82
|
-
end.reject
|
|
84
|
+
end.reject { |klass| klass.abstract_class? || @excluded_consumer_names.include?(klass.name) }
|
|
83
85
|
end
|
|
84
86
|
|
|
85
87
|
def boot
|
data/lib/lepus/version.rb
CHANGED