Class: Async::Container::Notify::Log
- Defined in:
- lib/async/container/notify/log.rb
Overview
Represents a client that uses a local log file to communicate readiness, status changes, etc.
Constant Summary collapse
- NOTIFY_LOG =
The name of the environment variable which contains the path to the notification socket.
"NOTIFY_LOG"
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
- #The path to the UNIX socket used for sending messages to the controller.(pathtotheUNIXsocketused) ⇒ Object readonly
Class Method Summary collapse
-
.open!(environment = ENV) ⇒ Object
Open a notification client attached to the current NOTIFY_LOG if possible.
- .path(environment = ENV) ⇒ Object
Instance Method Summary collapse
-
#error!(text, **message) ⇒ Object
Send the specified error.
-
#initialize(path) ⇒ Log
constructor
Initialize the notification client.
-
#send(**message) ⇒ Object
Send the given message.
Methods inherited from Client
#ready!, #reloading!, #restarting!, #status!, #stopping!
Constructor Details
#initialize(path) ⇒ Log
Initialize the notification client.
33 34 35 |
# File 'lib/async/container/notify/log.rb', line 33 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
38 39 40 |
# File 'lib/async/container/notify/log.rb', line 38 def path @path end |
#The path to the UNIX socket used for sending messages to the controller.(pathtotheUNIXsocketused) ⇒ Object (readonly)
38 |
# File 'lib/async/container/notify/log.rb', line 38 attr :path |
Class Method Details
.open!(environment = ENV) ⇒ Object
Open a notification client attached to the current NOTIFY_LOG if possible.
25 26 27 28 29 |
# File 'lib/async/container/notify/log.rb', line 25 def self.open!(environment = ENV) if path = self.path(environment) self.new(path) end end |
.path(environment = ENV) ⇒ Object
19 20 21 |
# File 'lib/async/container/notify/log.rb', line 19 def self.path(environment = ENV) environment[NOTIFY_LOG] end |
Instance Method Details
#error!(text, **message) ⇒ Object
Send the specified error. ‘sd_notify` requires an `errno` key, which defaults to `-1` to indicate a generic error.
52 53 54 55 56 |
# File 'lib/async/container/notify/log.rb', line 52 def error!(text, **) [:errno] ||= -1 super end |
#send(**message) ⇒ Object
Send the given message.
42 43 44 45 46 47 48 |
# File 'lib/async/container/notify/log.rb', line 42 def send(**) data = JSON.dump() File.open(@path, "a") do |file| file.puts(data) end end |