Class ModuleRepository

java.lang.Object
ai.pipestream.registration.repository.ModuleRepository

@ApplicationScoped public class ModuleRepository extends Object
Repository for managing service module registrations in PostgreSQL. This is the primary data store (system of record).

Blocking Hibernate ORM (Panache active-record) over JDBC. Write methods are @Transactional; reads run without a transaction. Callers invoke these from virtual threads, so the blocking JDBC work never pins the event loop.

  • Constructor Details

    • ModuleRepository

      public ModuleRepository()
  • Method Details

    • registerModule

      public ServiceModule registerModule(String serviceName, String host, int port, String version, Map<String,Object> metadata, String jsonSchema)
      Register a new service module with optional schema. Updates existing module if it already exists.
    • saveSchema

      public ConfigSchema saveSchema(String serviceName, String version, String jsonSchema)
      Save a configuration schema (dual storage: PostgreSQL + Apicurio).
    • updateHeartbeat

      public ServiceModule updateHeartbeat(String serviceId)
      Update heartbeat for a service.
    • markUnhealthy

      public ServiceModule markUnhealthy(String serviceId)
      Mark service as unhealthy.
    • unregisterModule

      public boolean unregisterModule(String serviceId)
      Unregister a service.
    • getActiveServices

      public List<ServiceModule> getActiveServices()
      Get all active services.
    • getAllServices

      public List<ServiceModule> getAllServices()
      Get all services (for admin dashboard).
    • findStaleServices

      public List<ServiceModule> findStaleServices()
      Find stale services (no heartbeat for > 30 seconds).
    • findById

      public ServiceModule findById(String serviceId)
      Get service by ID.
    • findSchemaById

      public ConfigSchema findSchemaById(String schemaId)
      Get schema by ID.
    • upsertNamedArtifact

      public ConfigSchema upsertNamedArtifact(String artifactName, String version, String json)
      Upsert a NAMED schema artifact (recipe schema, uischema, ...) as a ConfigSchema row keyed by the artifact name — same update-on-change semantics as module config schemas, so SNAPSHOT re-registrations refresh content and mark PENDING for Apicurio re-sync.
    • findLatestSchemaByServiceName

      public ConfigSchema findLatestSchemaByServiceName(String serviceName)
    • findCurrentSchemaByServiceName

      public ConfigSchema findCurrentSchemaByServiceName(String serviceName)
      Resolve the schema of the module's CURRENT registration: the instance with the freshest heartbeat wins. "Latest by createdAt" is wrong once historical version rows exist (e.g. a branch-suffixed snapshot version registered after the canonical one shadows it forever).
    • findSchemaVersionsByServiceName

      public List<ConfigSchema> findSchemaVersionsByServiceName(String serviceName)
      Get all schema versions for a service name, ordered by version descending.
    • findSchemasNeedingSync

      public List<ConfigSchema> findSchemasNeedingSync()
      Get all schemas needing sync to Apicurio.
    • countServicesByStatus

      public Map<ServiceStatus, Long> countServicesByStatus()
      Count registered services by status.