Skip to content

Commit 5cc27cf

Browse files
ioquatixsamuel-williams-shopify
authored andcommitted
Add Client#healthy! for health checks.
1 parent aed5dab commit 5cc27cf

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

lib/async/container/notify/client.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ def ready!(**message)
1717
send(ready: true, **message)
1818
end
1919

20+
# Notify the parent controller that the child is healthy.
21+
# @parameters message [Hash] Additional details to send with the message.
22+
def healthy!(**message)
23+
send(healthy: true, **message)
24+
end
25+
2026
# Notify the parent controller that the child is reloading.
2127
# @parameters message [Hash] Additional details to send with the message.
2228
def reloading!(**message)

releases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Introduce `Client#healthy!` for sending health check messages.
6+
37
## v0.28.0
48

59
- Add `startup_timeout` parameter to `spawn` and `run` methods for detecting processes that hang during startup and never become ready.

test/async/container/notify.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@
5151
end
5252
end
5353

54+
with "#healthy!" do
55+
it "sends healthy message" do
56+
context = server.bind
57+
58+
client.healthy!
59+
60+
message = context.receive
61+
62+
expect(message).to have_keys(
63+
healthy: be == true
64+
)
65+
end
66+
67+
it "sends healthy message with additional details" do
68+
context = server.bind
69+
70+
client.healthy!(status: "All systems operational", uptime: 3600)
71+
72+
message = context.receive
73+
74+
expect(message).to have_keys(
75+
healthy: be == true,
76+
status: be == "All systems operational",
77+
uptime: be == 3600
78+
)
79+
end
80+
end
81+
5482
with "#send" do
5583
it "sends message" do
5684
context = server.bind

0 commit comments

Comments
 (0)