Class JdbcAgentRegistry

java.lang.Object
dev.agenor.adapters.persistence.directory.JdbcAgentRegistry
All Implemented Interfaces:
AgentRegistry

public class JdbcAgentRegistry extends Object implements AgentRegistry
JDBC implementation of AgentRegistry.

register(dev.agenor.core.AgentDescriptor) uses upsert semantics (insert-then-update on PK conflict) to support agent restarts and node failover without requiring callers to distinguish first registration from re-registration. See ADR-023 for the singleton-per-agent-id contract.

Since:
0.22.0
  • Constructor Details

    • JdbcAgentRegistry

      public JdbcAgentRegistry(JdbcHelper helper)
    • JdbcAgentRegistry

      public JdbcAgentRegistry(JdbcHelper helper, AgenorTelemetry telemetry)
      Parameters:
      helper - JDBC helper; must not be null
      telemetry - telemetry for registry spans; null treated as noop
  • Method Details

    • register

      public CompletableFuture<Void> register(AgentDescriptor descriptor)
      Registers or updates an agent in the directory.

      On first registration inserts a new row. On re-registration (same agent_id, e.g. after a restart) updates all mutable fields except registered_at.

      Specified by:
      register in interface AgentRegistry
      Parameters:
      descriptor - the agent descriptor, must not be null
      Returns:
      a future that completes when registration succeeds
    • unregister

      public CompletableFuture<Void> unregister(String agentId)
      Description copied from interface: AgentRegistry
      Removes an agent from the directory.

      If the agent is not registered the call is a no-op.

      Specified by:
      unregister in interface AgentRegistry
      Parameters:
      agentId - the unique agent identifier, must not be null
      Returns:
      a future that completes when unregistration succeeds
    • updateStatus

      public CompletableFuture<Void> updateStatus(String agentId, AgentStatus status)
      Description copied from interface: AgentRegistry
      Updates the status of a registered agent.

      Implementations should also update the agent's lastSeen timestamp. If the agent is not registered the behaviour is implementation-defined (log-and-ignore is recommended for leniency).

      Specified by:
      updateStatus in interface AgentRegistry
      Parameters:
      agentId - the unique agent identifier, must not be null
      status - the new status, must not be null
      Returns:
      a future that completes when the update succeeds