Skip to content

CIRCE / DOCUMENTATION

Integrations

The single extension point: scan roots, lifecycle hooks and health checks.

Documentation menu

An integration is declared with defineIntegration and listed in integrations. Its setup(ctx) receives a constrained context:

Method Purpose
addScanRoot(category, path) Scan an extra folder for a module category.
onStart(hook) Before login and command registration.
onReady(hook) Once the gateway is ready, with the client.
onStop(hook) After shutdown.
every(intervalMs, task, options?) Interval task after ready; cleared on shutdown.
addHealthCheck(name, check) Named probe for /ready.
import { defineIntegration } from "@sxnnyside/circe";

export default defineIntegration({
  name: "database",
  setup(ctx) {
    ctx.onStart(async () => { await db.connect(); });
    ctx.onStop(async () => { await db.close(); });
    ctx.addHealthCheck("database", () => db.ping());
  },
});

An IntegrationError is raised if setup() throws or breaks its contract. Integrations cannot change global state, wrap incoming payloads or reorder routers.