{"modulePath":"github.com/osapi-io/osapi","version":"v0.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package controller\n\nPackage controller runs the controller process: the REST API, and the watchers and the heartbeat that run beside it.\n\n## Functions\n\n```go\nfunc OpenVaults(\n\tctx context.Context,\n\tnc *natsclient.Client,\n\tcfg config.Config,\n) (*vault.Set, error)\n```\nOpenVaults makes each vault of controller.secrets.vaults, with nc as the NATS connection of a type that needs one. A command that resolves a reference of the config, such as osapi controller token generate, opens the vaults with it, as the controller does.\n\n## Types\n\n```go\ntype Controller struct {\n\t// contains filtered or unexported fields\n}\n```\nController is the controller process.\n\n```go\nfunc New(\n\tctx context.Context,\n\tlog *slog.Logger,\n\tcfg config.Config,\n\topts ...Option,\n) (*Controller, error)\n```\nNew connects to NATS as cfg.Controller.NATS tells, and makes the REST API with each handler. It starts the heartbeat, and the enrollment and condition watchers that cfg turns on. They run until ctx ends. Start serves the API.\n\n```go\nfunc (c *Controller) CheckHealth(\n\tctx context.Context,\n) error\n```\nCheckHealth tells whether NATS and the jobs bucket answer.\n\n```go\nfunc (c *Controller) Start()\n```\nStart serves the REST API without blocking.\n\n```go\nfunc (c *Controller) Stop(\n\tctx context.Context,\n)\n```\nStop asks the REST API to stop, ends the health metrics refresh, then closes the NATS connection: nothing reads NATS after it closes.\n\n```go\nfunc (c *Controller) SubComponents() map[string]job.SubComponentInfo\n```\nSubComponents returns the parts of the controller that its heartbeat and its metrics server report.\n\n```go\nfunc (c *Controller) Vaults() *vault.Set\n```\nVaults are the vaults of controller.secrets.vaults, by name.\n\n```go\ntype Option func(*options)\n```\nOption changes how New makes the controller.\n\n```go\nfunc WithMeterProvider(\n\tmp *sdkmetric.MeterProvider,\n) Option\n```\nWithMeterProvider sends the HTTP metrics, the NATS metrics and the job metrics of the controller to mp.\n\n```go\nfunc WithVersion(\n\tversion string,\n) Option\n```\nWithVersion is the build version of the binary, such as v0.2.1-0.20261119003517-f6bc5af55ceb. The heartbeat and the health status report it; the UI, which the controller serves, shows it.\n\n","path":"github.com/osapi-io/osapi/internal/controller","name":"controller","synopsis":"Package controller runs the controller process: the REST API, and the watchers and the heartbeat that run beside it.","isRedistributable":true}
