Class: Async::Container::Notify::Client

Inherits:
Object
  • Object
show all
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.

Direct Known Subclasses

Console, Log, Pipe, Socket

Instance Method Summary collapse

Instance Method Details

#error!(text, **message) ⇒ Object

Notify the parent controller of an error condition.



63
64
65
# File 'lib/async/container/notify/client.rb', line 63

def error!(text, **message)
	send(status: text, **message)
end

#healthy!(**message) ⇒ Object

Notify the parent controller that the child is healthy.



22
23
24
# File 'lib/async/container/notify/client.rb', line 22

def healthy!(**message)
	send(healthy: true, **message)
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!(**message)
	send(ready: true, **message)
end

#reloading!(**message) ⇒ Object

Notify the parent controller that the child is reloading.



28
29
30
31
32
33
34
# File 'lib/async/container/notify/client.rb', line 28

def reloading!(**message)
	message[:ready] = false
	message[:reloading] = true
	message[:status] ||= "Reloading..."
	
	send(**message)
end

#restarting!(**message) ⇒ Object

Notify the parent controller that the child is restarting.



38
39
40
41
42
43
44
# File 'lib/async/container/notify/client.rb', line 38

def restarting!(**message)
	message[:ready] = false
	message[:reloading] = true
	message[:status] ||= "Restarting..."
	
	send(**message)
end

#status!(text) ⇒ Object

Notify the parent controller of a status change.



56
57
58
# File 'lib/async/container/notify/client.rb', line 56

def status!(text)
	send(status: text)
end

#stopping!(**message) ⇒ Object

Notify the parent controller that the child is stopping.



48
49
50
51
52
# File 'lib/async/container/notify/client.rb', line 48

def stopping!(**message)
	message[:stopping] = true
	
	send(**message)
end