Categories:
Agent Deployment Plugin
The agent-deployment plugin is a component that provides deployment functionalities for agents within the agents-manager.
Introduction
The agent-deployment plugin is designed to manage the deployment of agents in a flexible and scalable manner. It allows multiple agents to be deployed within a single microservice, and the same agent can be deployed with different configurations across different microservices or within the same microservice.
Plugin Management
The agent-deployment plugin uses the @architect/architect library for managing dependencies and plugin lifecycle. The PluginManager module, located in the modules/plugin-manager folder, is responsible for initializing the plugin at the start-up of the agents-manager.
The PluginManager performs the following tasks:
- Initializes the architect application with the plugins defined in the
plugin-config.jsonfile, located at the root of the agents-manager component. - Adds core modules to the IOC context. See the section plugin modules.
- Stores information about each module defined in the plugins.
Plugin Basic Structure
A basic plugin must define at least:
- A
package.jsonfile defining the library, with apluginsection specifying which modules it consumes and supplies. - A source code file that defines the modules it supplies (
index.tsfor example).
The structure of this basic plugin is as follows:
agent-deployment-plugin
├── index.ts
└── package.json
Example index.ts
import { PluginType, registerPlugin } from '@telefonica/agents-manager-common';
import { Services } from './deployment-consume-services';
export = registerPlugin([
{
type: PluginType.Service,
name: 'agentDeploymentService',
instance: {
deployAgent(agentConfig) {
// Implementation for deploying an agent
}
},
services: Services
}
]);
Example package.json
{
"name": "@telefonica/agent-deployment-plugin",
"version": "1.0.0",
"main": "index.js",
"private": true,
"plugin": {
"consumes": [
"configurationManager"
],
"provides": [
"agentDeploymentService"
]
}
}
Plugin Modules
The agent-deployment plugin can utilize the following modules provided by the agents-manager:
- configurationManager: Module with the agents-manager configuration information.
- redisConnector: Module with the agents-manager Redis connection.
A plugin can provide one or more plugin modules, and each plugin module can be of a different type. Each type of module is intended to add specific functionality to the agents-manager.