Skip to main content

Setup

Registers the CacheService handler on the SetupContext mux. This function requires sc.DB and sc.DataStore to be set by the standalone binary, runs database migrations, sets up OpenTelemetry providers and interceptors, and adds a ready check for the database and data store.

def Setup(
ctx: context.Context,
sc: *app.SetupContext
) - > error

Registers the CacheService handler on the SetupContext mux. This function initializes the CacheService, runs necessary database migrations, sets up OpenTelemetry for tracing and metrics, and adds a ready check to ensure database and data store connectivity. Callers use this to integrate the CacheService into their application's setup process.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for controlling cancellation and timeouts during the setup process.
sc*app.SetupContextThe application setup context, which must have sc.DB and sc.DataStore initialized. This context provides the multiplexer (Mux) to register the CacheService handler, the database connection (DB) for migrations and health checks, and the data store (DataStore) for health checks.

Returns

TypeDescription
errorAn error if any step of the setup process fails, such as migration failures, OpenTelemetry setup issues, or if the CacheService handler cannot be created.