Agent Methods
Introduction
These methods are related to checking the access of an Agent, before using it.
This methods are accessed via the “n2.n2svcd” module:
local n2svcd = require "n2.n2svcd"
.agent_access [Asynchronous]
The agent_access method checks the application access level of a Lua Agent.
In all practical terms this means checking the application access of the underlying “other” n2svcd applications
which this agent uses to perform its function. For example, a DB agent will use a DBApp to perform its function,
and hence will consider the DBApp’s access when returning the agent access value.
An agent which does not rely on other n2svcd applications to perform its function will always return ACCESS_ONLINE.
The agent_access method takes the following parameters.
| Parameter | Type | Description |
|---|---|---|
action
|
String | The agent key of the action of which to check the access. |
route
|
String |
The routing specifier, for agents which support hand-off of requests to more than one application. (Default = The default application configured for this agent) |
Example:
local db_access = n2svcd.agent_access ("db")
The agent_access method returns one of the following application access constants.
-- # [DOCUMENTED] Availability - ACCESS
-- #
-- # UNREACHABLE:
-- # Used only for Client Socket Handles or ManageApp API responses.
-- # Applies when the connection is down, or
-- # Applies for new connections (not yet received !AVAILABILITY)
-- #
n2svcd.ACCESS_UNREACHABLE = 0
-- # SHUTDOWN:
-- # At shutdown after receiving !SHUTDOWN-NOW (and not UNREACHABLE).
-- #
n2svcd.ACCESS_SHUTDOWN = 1
-- # STARTUP:
-- # At startup before ->prepare () has been called (and not UNREACHABLE).
-- # An application can go online after ->prepare () and before ->showtime ().
-- #
n2svcd.ACCESS_STARTUP = 2
-- # OFFLINE:
-- # Whenever ->adjust_status () calls ->set_online_load (0) (and not UNREACHABLE/SHUTDOWN/STARTUP).
-- #
n2svcd.ACCESS_OFFLINE = 3
-- # QUIESCING:
-- # Whenever the application would otherwise be ONLINE, except that:
-- # The {quiescing} attribute is set by the administrator via the Management API, OR
-- # The shutdown process is between !SHUTDOWN-NOTICE and !SHUTDOWN-NOW.
-- #
n2svcd.ACCESS_QUIESCING = 4
-- # ONLINE:
-- # Whenever ->adjust_status () calls ->set_online_load (1) (and not UNREACHABLE/SHUTDOWN/STARTUP/QUIESCING).
-- #
n2svcd.ACCESS_ONLINE = 5
.agent_online [Asynchronous]
A simplified version of agent_access which returns true when the agent is ACCESS_ONLINE and false otherwise.
The agent_online method takes the following parameters.
| Parameter | Type | Description |
|---|---|---|
action
|
String | The agent key of the action of which to check the access. |
route
|
String |
The routing specifier, for agents which support hand-off of requests to more than one application. (Default = The default application configured for this agent) |
local alt_online = n2svcd.agent_online ("db", "alt")