Agent Service
This service provides a handle to spawn sequence manager and sequence components, to kill the components.
Agent service has following APIs:
API | Input args | Returns |
---|---|---|
spawnSequenceManager | agentPrefix, obsModeConfigPath, isConfigLocal, version | SpawnResponse |
spawnSequenceComponent | agentPrefix, componentName, version | SpawnResponse |
killComponent | connection | KillResponse |
Creation of Agent Service
Pre-requisite
In order to use agent service APIs:
- Agent machine should be up and running. Its location should be registered with location service.
- Authorization Token with correct access role. To read more on how to fetch access token, click here.
To create Agent client
- Typescript
-
const tokenFactory = () => auth.token const agentService: AgentService = await AgentService(tokenFactory)
APIs
spawnSequenceManager
This API spawns new sequence manager on given agent machine.
It takes prefix of the agent machine on which sequence manager needs to be spawned. Observation mode config file can be present on local(agent machine) or on config server. In case of local file, absolute path should be provided. Sequence manager version is an optional field. When version isn’t specified, default version gets picked up.
API returns Spawned
as a response when sequence manager has spawned successfully. API returns Failed
as a response if a sequence manager is already present.
The following example shows how to call spawnSequenceManager API :
- Typescript
-
const agentPrefix = new Prefix('ESW', 'agent1') const obsModeConfigPath = '/obs-mode.conf' const sequenceManagerVersion = '1.0.0' const spawnResponse1 = agentService.spawnSequenceManager( agentPrefix, obsModeConfigPath, false, sequenceManagerVersion )
spawnSequenceComponent
This API spawns new sequence component on given agent machine.
It takes prefix of the agent machine, component name and ocs-app library version. Version is an optional field. When version isn’t specified, default version gets picked up.
API returns Spawned
as a response when sequence component has spawned successfully. API returns Failed
as a response if a sequence component with given component name and agent’s subsystem is already present on any agent machine.
The following example shows how to call spawnSeqeunceComponent API :
- Typescript
-
const ocsAppVersion = '1.2.1' const spawnResponse2 = agentService.spawnSequenceComponent( agentPrefix, 'component1', ocsAppVersion )
killComponent
This API is used to kill any component registered with location service. It takes Connection
as a input which can be either of following: AkkaConnection
, HttpConnection
, TcpConnection
.
API returns Killed
as a response if component is killed successfully. API returns Failed
as a response if it fails to kill the component.
The following example shows how to call killComponent API :