Documentation
¶
Overview ¶
Package server runs the embedded NATS server that osapi starts for itself, and writes its heartbeat.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SubComponents ¶
func SubComponents( sc config.NATSServer, ) map[string]job.SubComponentInfo
SubComponents returns the parts of the embedded NATS server that its heartbeat and its metrics server report.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the embedded NATS server. It keeps one client connection to itself, for its heartbeat.
func New ¶
func New( ctx context.Context, log *slog.Logger, cfg config.NATS, mp *sdkmetric.MeterProvider, ) (*Server, error)
New starts the embedded NATS server that cfg.Server describes, connects to it, and creates osapi's streams and buckets with bus.Setup. If a step fails, New stops the server and returns the error.
func (*Server) Start ¶
func (s *Server) Start()
Start does nothing. New starts the server, because bus.Setup needs it to run first.
func (*Server) StartHeartbeat ¶
func (s *Server) StartHeartbeat( ctx context.Context, version string, conditions config.ProcessConditions, )
StartHeartbeat writes the registration of the server to the registry KV bucket until ctx ends, with version, the build version of the binary. If the config names no registry bucket, it logs a warning and returns, because the server runs without a heartbeat.