protobuf-nats 0.13.1.pre2 → 0.13.1.pre3
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/README.md +5 -0
- data/lib/protobuf/nats/config.rb +15 -1
- data/lib/protobuf/nats/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: b128192ffd9cfa77982eee74b65d2c1fc47d7718549cd96926f69e957ea46aa8
|
|
4
|
+
data.tar.gz: 40d7f971ee6686355c4f342ebd34066577ce863291538695f6cf1569b74b21be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab180b3ad24455f710daf101a8bc51413e77e6bf5e3c928132d88cd299e6b024b212e6d01187d4d6c90b53f8e38baa7bebe5ab920f52a91aeeb76663b496b76b
|
|
7
|
+
data.tar.gz: 71d4d11af63fb10d4fd061294f2ae64ed778582bae3ccc5762dda15f4644f843ca09361398508436c80d1c9f3b834d42af957b752387917f44675102ff45975e
|
data/README.md
CHANGED
|
@@ -82,6 +82,10 @@ is saturating the pool and the server is NACKing healthy traffic (default: false
|
|
|
82
82
|
|
|
83
83
|
`PB_NATS_RESPONSE_MUXER_DISPATCHERS` - Number of dispatcher threads draining the shared response subscription (see [ResponseMuxer](#how-it-works)). Defaults to `Concurrent.processor_count` on JRuby (true parallelism) and `1` on CRuby (the GVL makes extra dispatchers pointless). Minimum of 1.
|
|
84
84
|
|
|
85
|
+
`PB_NATS_CONNECTION_NAME` - A friendly name for the NATS connection, surfaced in NATS server monitoring, error
|
|
86
|
+
reporting, and debugging. Shared by both the client and server connections. Precedence: this env var > the
|
|
87
|
+
`connection_name` yaml key > the hostname (`Socket.gethostname`), so the connection is never nameless (default: hostname).
|
|
88
|
+
|
|
85
89
|
`PROTOBUF_NATS_CONFIG_PATH` - Custom path to the config yaml (default: "config/protobuf_nats.yml").
|
|
86
90
|
|
|
87
91
|
### YAML Config
|
|
@@ -104,6 +108,7 @@ An example config looks like this:
|
|
|
104
108
|
- "nats://127.0.0.1:4223"
|
|
105
109
|
- "nats://127.0.0.1:4224"
|
|
106
110
|
max_reconnect_attempts: 500
|
|
111
|
+
connection_name: "my-service"
|
|
107
112
|
uses_tls: true
|
|
108
113
|
tls_client_cert: "/path/to/client-cert.pem"
|
|
109
114
|
tls_client_key: "/path/to/client-key.pem"
|
data/lib/protobuf/nats/config.rb
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
require "erb"
|
|
2
2
|
require "openssl"
|
|
3
|
+
require "socket"
|
|
3
4
|
require "yaml"
|
|
4
5
|
|
|
5
6
|
module Protobuf
|
|
6
7
|
module Nats
|
|
7
8
|
class Config
|
|
8
|
-
attr_accessor :uses_tls, :servers, :connect_timeout, :tls_client_cert, :tls_client_key, :tls_ca_cert, :max_reconnect_attempts
|
|
9
|
+
attr_accessor :uses_tls, :servers, :connect_timeout, :tls_client_cert, :tls_client_key, :tls_ca_cert, :max_reconnect_attempts, :connection_name
|
|
9
10
|
attr_accessor :server_subscription_key_do_not_subscribe_to_when_includes_any_of,
|
|
10
11
|
:server_subscription_key_only_subscribe_to_when_includes_any_of,
|
|
11
12
|
:subscription_key_replacements
|
|
@@ -16,6 +17,7 @@ module Protobuf
|
|
|
16
17
|
:connect_timeout => nil,
|
|
17
18
|
:max_reconnect_attempts => 60_000,
|
|
18
19
|
:servers => nil,
|
|
20
|
+
:connection_name => nil,
|
|
19
21
|
:tls_client_cert => nil,
|
|
20
22
|
:tls_client_key => nil,
|
|
21
23
|
:tls_ca_cert => nil,
|
|
@@ -78,12 +80,24 @@ module Protobuf
|
|
|
78
80
|
servers: servers,
|
|
79
81
|
max_reconnect_attempts: max_reconnect_attempts,
|
|
80
82
|
connect_timeout: connect_timeout,
|
|
83
|
+
# A friendly connection name surfaces in NATS server monitoring,
|
|
84
|
+
# error reporting, and debugging (highly recommended by the NATS
|
|
85
|
+
# docs). Shared by both the client and server connections since both
|
|
86
|
+
# build from this hash.
|
|
87
|
+
name: resolved_connection_name,
|
|
81
88
|
}
|
|
82
89
|
options[:tls] = {:context => new_tls_context} if uses_tls
|
|
83
90
|
options
|
|
84
91
|
end
|
|
85
92
|
end
|
|
86
93
|
|
|
94
|
+
# Precedence: PB_NATS_CONNECTION_NAME env var > yaml/DEFAULT connection_name
|
|
95
|
+
# > hostname. Env wins so ops can set a per-pod/per-host name without a
|
|
96
|
+
# config file; the hostname fallback ensures the name is never blank.
|
|
97
|
+
def resolved_connection_name
|
|
98
|
+
::ENV["PB_NATS_CONNECTION_NAME"] || connection_name || ::Socket.gethostname
|
|
99
|
+
end
|
|
100
|
+
|
|
87
101
|
def new_tls_context
|
|
88
102
|
tls_context = ::OpenSSL::SSL::SSLContext.new
|
|
89
103
|
# Floor at TLS 1.2, ceiling at TLS 1.3 (replaces the deprecated
|