connectrpc-health 0.1.2 → 0.2.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 +4 -4
- data/README.md +28 -10
- data/lib/connectrpc/health/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8142b2b651a0b3a032b54f8d80fac8e38bbfbfee019771fc1bf98ef0ad1aba5a
|
|
4
|
+
data.tar.gz: 10fc6a3480781fd87bfcbf2a1fd89024948e03fa17b6a516b1068b4a9383acf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 783b22bc18dd0df6cbdef401887fcfabe8b719a221f5df7245939244ae6de6a870b746461d893b1f7cdf12f9853a40f2b8aa3605187fed20cf72ea6a66f2300f
|
|
7
|
+
data.tar.gz: fcc050a134e3d5afa5d20b10e2f6b2a6a38915397e15694ca65d40deb46dada8eb6b5ae60b8ab937bc4a5fbba4322b3e260fb89c19bd3100c351bbe54d9109d7
|
data/README.md
CHANGED
|
@@ -27,10 +27,10 @@ and adoption gates.
|
|
|
27
27
|
## Installation
|
|
28
28
|
|
|
29
29
|
```ruby
|
|
30
|
-
gem "connectrpc-health", "~> 0.
|
|
30
|
+
gem "connectrpc-health", "~> 0.2.0"
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
The runtime dependencies are `connectrpc ~> 0.
|
|
33
|
+
The runtime dependencies are `connectrpc ~> 0.2.0` and
|
|
34
34
|
`google-protobuf >= 4.36.2, < 5`. Core and the hosting packages do not depend
|
|
35
35
|
on this package.
|
|
36
36
|
|
|
@@ -110,20 +110,38 @@ worker-local. Set statuses inside each worker, for example while building
|
|
|
110
110
|
|
|
111
111
|
### Authentication
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
Server [interceptors](../../docs/unary.md#interceptors) on the application's
|
|
114
|
+
`Server` cover Check and List through `server_unary` and Watch through
|
|
115
|
+
`server_stream`. To expose health behind authentication, reject before `yield`
|
|
116
|
+
so a denied call never reaches the registry. A denied Watch then reveals no
|
|
117
|
+
status and allocates no watcher. `invoker:` is not enough: it covers unary
|
|
118
|
+
calls only, and Watch bypasses it.
|
|
116
119
|
|
|
117
120
|
```ruby
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
class HealthAuth
|
|
122
|
+
def server_unary(call, &) = authorize!(call, &)
|
|
123
|
+
def server_stream(call, &) = authorize!(call, &)
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
# authorized?(context) is the application's own check, for example of a
|
|
128
|
+
# credential in context.request_metadata.
|
|
129
|
+
def authorize!(call)
|
|
130
|
+
if call.method.service == ConnectRPC::Health::SERVICE.name && !authorized?(call.context)
|
|
131
|
+
raise ConnectRPC::Error.new(:unauthenticated, "credentials required")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
yield
|
|
135
|
+
end
|
|
124
136
|
end
|
|
137
|
+
|
|
138
|
+
server = ConnectRPC::Server.new(services: services, handlers: handlers, binding: binding,
|
|
139
|
+
protocol: :auto, interceptors: [HealthAuth.new])
|
|
125
140
|
```
|
|
126
141
|
|
|
142
|
+
An interceptor's `server_stream` frame, and anything it holds, lasts as long as
|
|
143
|
+
the Watch stream. Avoid holding scarce resources across `yield`.
|
|
144
|
+
|
|
127
145
|
## Shutdown and drain
|
|
128
146
|
|
|
129
147
|
Call `health.shutdown` before `host.close(grace:)`. Every entry becomes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: connectrpc-health
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jimeh
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.2.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.2.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: google-protobuf
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|