Skip to content

API -> Agent Server communication and connection caching #54

@agalitsyn

Description

@agalitsyn

Currently API calls agent server in direct manner, using model files and db connection.

What I consider to refactor

  • Create AgentServerClient and pin all methods here, mimic for client-server communication. Under the hood it still will use models and direct DB connection, but we will refactor handlers and prepare client layer for future refactoring too, when server API will be ready.
  • Refactor cache layer for server connections (minio + mysql). Move this to client implementation.
    • If we need to get data from server, we will do smth like client := agentServerClient.WithWEndpoint(agentServerHash) and then return a connected client. It means that if we do not have connection, we create it now and put into cache.
    • Return proper error if server is not responding
    • Remove connection if server was deleted using API method
    • Create connection if server was added using API method
    • Use mysql connnector with retry policy, already presented in mysql lib
  • 4 API handlers have similar code for fetching modules - /agents, /agents/hash, /groups, /groups/hash. This needs caching too, probably on AgentServerClient level

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

🆕 New

Relationships

None yet

Development

No branches or pull requests

Issue actions