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.
-- # Application is Starting Up or Shutting Down.
-- # We will reject ALL user messages. We will still accept management messages.
n2svcd.ACCESS_SHUTDOWN = 0
-- # Application is not currently available to perform functions.
-- # It is almost certain that any user request you give us will fail.
n2svcd.ACCESS_OFFLINE = 1
-- # Application is Quiescing. Shutdown Notice received, or user-requested.
-- # We will reject ALL new user session but will complete existing transactions.
n2svcd.ACCESS_QUIESCING = 2
-- # Application has some/full connectivity and you can send requests.
-- # If you have a choice of more than one ONLINE application you should look at that load %.
n2svcd.ACCESS_ONLINE = 3
.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")