omq 0.3.0 → 0.3.1
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 +7 -0
- data/exe/omqcat +32 -29
- data/lib/omq/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: 3d77750001a2c45808301e5a005f83c8a6f4df44ffa033aa121cc9229b597347
|
|
4
|
+
data.tar.gz: b009c94d5ea30d5e0983831fb443e1ceb31e8980725b1b9c75b9403814a7a469
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6612b16ae23874f1539154f108359190ac70eeaf9691c326deb4b2545151590e4458071912a987258b9d59cf80c5015024fbfa546d1f5bbcd979564be5cdffe
|
|
7
|
+
data.tar.gz: 7706e73997b1a96446e6c5e6053756e57e4b33d6b084a82c49f78e40b9454aa26aed1d5e3ca14207c450be75864707618c3a87cf27c750020064393dbe85c71f
|
data/CHANGELOG.md
CHANGED
data/exe/omqcat
CHANGED
|
@@ -12,29 +12,9 @@
|
|
|
12
12
|
# omqcat sub -c tcp://localhost:5556 -s "weather."
|
|
13
13
|
#
|
|
14
14
|
|
|
15
|
-
require "omq"
|
|
16
|
-
require "async"
|
|
17
15
|
require "optparse"
|
|
18
|
-
require "json"
|
|
19
|
-
require "console"
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
HAS_ZSTD = begin; require "zstd-ruby"; true; rescue LoadError; false; end
|
|
23
|
-
|
|
24
|
-
SOCKET_TYPES = {
|
|
25
|
-
"req" => OMQ::REQ,
|
|
26
|
-
"rep" => OMQ::REP,
|
|
27
|
-
"pub" => OMQ::PUB,
|
|
28
|
-
"sub" => OMQ::SUB,
|
|
29
|
-
"push" => OMQ::PUSH,
|
|
30
|
-
"pull" => OMQ::PULL,
|
|
31
|
-
"pair" => OMQ::PAIR,
|
|
32
|
-
"dealer" => OMQ::DEALER,
|
|
33
|
-
"router" => OMQ::ROUTER,
|
|
34
|
-
}.freeze
|
|
35
|
-
|
|
36
|
-
SEND_ONLY = [OMQ::PUB, OMQ::PUSH].freeze
|
|
37
|
-
RECV_ONLY = [OMQ::SUB, OMQ::PULL].freeze
|
|
17
|
+
SOCKET_TYPE_NAMES = %w[req rep pub sub push pull pair dealer router].freeze
|
|
38
18
|
|
|
39
19
|
|
|
40
20
|
# ── Option parsing ──────────────────────────────────────────────────
|
|
@@ -61,7 +41,7 @@ opts = {
|
|
|
61
41
|
|
|
62
42
|
parser = OptionParser.new do |o|
|
|
63
43
|
o.banner = "Usage: omqcat TYPE [options]\n\n" \
|
|
64
|
-
"Types: #{
|
|
44
|
+
"Types: #{SOCKET_TYPE_NAMES.join(', ')}\n\n"
|
|
65
45
|
|
|
66
46
|
o.separator "Connection:"
|
|
67
47
|
o.on("-c", "--connect URL", "Connect to endpoint (repeatable)") { |v| opts[:connects] << v }
|
|
@@ -102,7 +82,7 @@ parser = OptionParser.new do |o|
|
|
|
102
82
|
o.separator "\nOther:"
|
|
103
83
|
o.on("-v", "--verbose", "Print connection events to stderr") { opts[:verbose] = true }
|
|
104
84
|
o.on("-q", "--quiet", "Suppress message output") { opts[:quiet] = true }
|
|
105
|
-
o.on("-V", "--version") { puts "omqcat #{OMQ::VERSION}"; exit }
|
|
85
|
+
o.on("-V", "--version") { require "omq"; puts "omqcat #{OMQ::VERSION}"; exit }
|
|
106
86
|
o.on("-h", "--help") { puts o; exit }
|
|
107
87
|
end
|
|
108
88
|
|
|
@@ -114,16 +94,39 @@ end
|
|
|
114
94
|
|
|
115
95
|
type_name = ARGV.shift
|
|
116
96
|
abort parser.to_s unless type_name
|
|
117
|
-
|
|
118
|
-
abort "Unknown socket type: #{type_name}. Known: #{SOCKET_TYPES.keys.join(', ')}" unless klass
|
|
97
|
+
abort "Unknown socket type: #{type_name}. Known: #{SOCKET_TYPE_NAMES.join(', ')}" unless SOCKET_TYPE_NAMES.include?(type_name.downcase)
|
|
119
98
|
|
|
120
|
-
# ── Validation
|
|
99
|
+
# ── Validation (fast, before loading gems) ──────────────────────────
|
|
121
100
|
|
|
122
101
|
abort "At least one --connect or --bind is required" if opts[:connects].empty? && opts[:binds].empty?
|
|
123
102
|
abort "--data and --file are mutually exclusive" if opts[:data] && opts[:file]
|
|
124
|
-
abort "--subscribe is only valid for SUB" if !opts[:subscribes].empty? &&
|
|
125
|
-
abort "--identity is only valid for DEALER/ROUTER" if opts[:identity] &&
|
|
126
|
-
abort "--target is only valid for ROUTER" if opts[:target] &&
|
|
103
|
+
abort "--subscribe is only valid for SUB" if !opts[:subscribes].empty? && type_name.downcase != "sub"
|
|
104
|
+
abort "--identity is only valid for DEALER/ROUTER" if opts[:identity] && !%w[dealer router].include?(type_name.downcase)
|
|
105
|
+
abort "--target is only valid for ROUTER" if opts[:target] && type_name.downcase != "router"
|
|
106
|
+
|
|
107
|
+
# ── Load gems ───────────────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
require "omq"
|
|
110
|
+
require "async"
|
|
111
|
+
require "json"
|
|
112
|
+
require "console"
|
|
113
|
+
|
|
114
|
+
HAS_MSGPACK = begin; require "msgpack"; true; rescue LoadError; false; end
|
|
115
|
+
HAS_ZSTD = begin; require "zstd-ruby"; true; rescue LoadError; false; end
|
|
116
|
+
|
|
117
|
+
SOCKET_TYPES = {
|
|
118
|
+
"req" => OMQ::REQ, "rep" => OMQ::REP,
|
|
119
|
+
"pub" => OMQ::PUB, "sub" => OMQ::SUB,
|
|
120
|
+
"push" => OMQ::PUSH, "pull" => OMQ::PULL,
|
|
121
|
+
"pair" => OMQ::PAIR,
|
|
122
|
+
"dealer" => OMQ::DEALER, "router" => OMQ::ROUTER,
|
|
123
|
+
}.freeze
|
|
124
|
+
|
|
125
|
+
SEND_ONLY = [OMQ::PUB, OMQ::PUSH].freeze
|
|
126
|
+
RECV_ONLY = [OMQ::SUB, OMQ::PULL].freeze
|
|
127
|
+
|
|
128
|
+
klass = SOCKET_TYPES[type_name.downcase]
|
|
129
|
+
|
|
127
130
|
abort "--msgpack requires the msgpack gem" if opts[:format] == :msgpack && !HAS_MSGPACK
|
|
128
131
|
abort "--compress requires the zstd-ruby gem" if opts[:compress] && !HAS_ZSTD
|
|
129
132
|
|
data/lib/omq/version.rb
CHANGED