Async::ContainerSourceAsyncContainerNotifyLog

class Log

Represents a client that uses a local log file to communicate readiness, status changes, etc.

Definitions

NOTIFY_LOG = "NOTIFY_LOG"

The name of the environment variable which contains the path to the notification socket.

def self.path(environment = ENV)

Signature

returns String

The path to the notification log file.

parameter environment Hash

The environment variables, defaults to ENV.

Implementation

def self.path(environment = ENV)
	environment[NOTIFY_LOG]
end

attr :path

Signature

attribute String

The path to the UNIX socket used for sending messages to the controller.

def self.open!(environment = ENV)

Open a notification client attached to the current NOTIFY_LOG = "NOTIFY_LOG" if possible.

Signature

parameter environment Hash

The environment variables, defaults to ENV.

Implementation

def self.open!(environment = ENV)
	if path = self.path(environment)
		self.new(path)
	end
end

def initialize(path)

Initialize the notification client.

Signature

parameter path String

The path to the UNIX socket used for sending messages to the process manager.

Implementation

def initialize(path)
	@path = path
end

def send(**message)

Send the given message.

Signature

parameter message Hash

Implementation

def send(**message)
	data = JSON.dump(message)
	
	File.open(@path, "a") do |file|
		file.puts(data)
	end
end

def error!(text, **message)

Send the specified error. sd_notify requires an errno key, which defaults to -1 to indicate a generic error.

Implementation

def error!(text, **message)
	message[:errno] ||= -1
	
	super
end