Class: Async::Container::Notify::Client
- Inherits:
-
Object
- Object
- Async::Container::Notify::Client
- Defined in:
- lib/async/container/notify/client.rb
Overview
Represents a client that can send messages to the parent controller in order to notify it of readiness, status changes, etc.
A process readiness protocol (e.g. ‘sd_notify`) is a simple protocol for a child process to notify the parent process that it is ready (e.g. to accept connections, to process requests, etc). This can help dependency-based startup systems to start services in the correct order, and to handle failures gracefully.
Instance Method Summary collapse
-
#error!(text, **message) ⇒ Object
Notify the parent controller of an error condition.
-
#ready!(**message) ⇒ Object
Notify the parent controller that the child has become ready, with a brief status message.
-
#reloading!(**message) ⇒ Object
Notify the parent controller that the child is reloading.
-
#restarting!(**message) ⇒ Object
Notify the parent controller that the child is restarting.
-
#status!(text) ⇒ Object
Notify the parent controller of a status change.
-
#stopping!(**message) ⇒ Object
Notify the parent controller that the child is stopping.
Instance Method Details
#error!(text, **message) ⇒ Object
Notify the parent controller of an error condition.
57 58 59 |
# File 'lib/async/container/notify/client.rb', line 57 def error!(text, **) send(status: text, **) end |
#ready!(**message) ⇒ Object
Notify the parent controller that the child has become ready, with a brief status message.
16 17 18 |
# File 'lib/async/container/notify/client.rb', line 16 def ready!(**) send(ready: true, **) end |
#reloading!(**message) ⇒ Object
Notify the parent controller that the child is reloading.
22 23 24 25 26 27 28 |
# File 'lib/async/container/notify/client.rb', line 22 def reloading!(**) [:ready] = false [:reloading] = true [:status] ||= "Reloading..." send(**) end |
#restarting!(**message) ⇒ Object
Notify the parent controller that the child is restarting.
32 33 34 35 36 37 38 |
# File 'lib/async/container/notify/client.rb', line 32 def restarting!(**) [:ready] = false [:reloading] = true [:status] ||= "Restarting..." send(**) end |
#status!(text) ⇒ Object
Notify the parent controller of a status change.
50 51 52 |
# File 'lib/async/container/notify/client.rb', line 50 def status!(text) send(status: text) end |
#stopping!(**message) ⇒ Object
Notify the parent controller that the child is stopping.
42 43 44 45 46 |
# File 'lib/async/container/notify/client.rb', line 42 def stopping!(**) [:stopping] = true send(**) end |