server

package
v0.0.0-...-5bd6654 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server implements the WebSocket service described in docs/PROTOCOL.md, connecting downstream sessions to hark.Engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Tokens        []string      // empty: no authentication
	Default       string        // default engine name
	MaxSession    time.Duration // max duration of one session; 0 = unlimited
	FinishTimeout time.Duration // how long to wait for upstream to finalize after finish (also bounds each rollover)
	// Rollover bounds how much audio one engine stream receives before the session moves to a fresh stream at a
	// pause (see session.Options.Rollover). 0 = session.DefaultRollover.
	Rollover time.Duration
	// AudioQueue is how much audio each engine track buffers; when full, backpressure applies.
	AudioQueue time.Duration
	// StallTimeout is how long to wait at most once a track's audio queue is full; beyond it the engine is considered stuck and only that track is ended.
	StallTimeout time.Duration
	// SpoolDir is where output-mode final tracks keep committed text beyond 64KB until track_end; "" = os.TempDir().
	SpoolDir string
	// Vocab is the personal vocabulary store; nil means disabled.
	Vocab *vocab.Store
}

type Instance

type Instance struct {
	Name   string
	Type   string
	Engine hark.Engine
}

Instance is a configured engine instance.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config, instances []Instance, log *slog.Logger) (*Server, error)

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context)

Shutdown stops accepting new connections and sessions. In-flight sessions may finish normally until ctx expires; those still running then are aborted with shutting_down. It returns only after sessions have wrapped up (all engine Streams closed) and all connections are closed; after that the engine instances can be closed safely. ctx only sets the grace period and does not bound the return time (a hung engine is left to the process manager). It may be called more than once.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL