Documentation
¶
Overview ¶
Package server provides the HTTP server with dependency injection for all application services.
Index ¶
- Variables
- func SyncSeqFromDB(ctx context.Context, storeClient store.Store, cacheClient cache.Cache, ...) error
- type AgentRunner
- type HealthResponse
- type Option
- func WithAgent(a AgentRunner) Option
- func WithCache(c cache.Cache) Option
- func WithConfig(cfg *config.Config) Option
- func WithConnectionManager(cm *websocket.ConnectionManager) Option
- func WithLogLevel(lv *slog.LevelVar) Option
- func WithLogger(l *slog.Logger) Option
- func WithQueue(q task.TaskQueue) Option
- func WithQueueManager(qm task.Manager) Option
- func WithReadyFunc(fn func()) Option
- func WithSessionHandler(h SessionDelegate) Option
- func WithStatisticsStore(ss agent.StatisticsStore) Option
- func WithStore(s store.Store) Option
- func WithTelemetry(te *telemetry.Telemetry) Option
- func WithWebhookStore(ws webhook.Store) Option
- type SenderAdapter
- type Server
- type SessionDelegate
- type SessionUpdateWriter
Constants ¶
This section is empty.
Variables ¶
var ErrMissingDependency = errors.New("missing required dependency")
ErrMissingDependency is returned when a required dependency is nil.
Functions ¶
func SyncSeqFromDB ¶
func SyncSeqFromDB(ctx context.Context, storeClient store.Store, cacheClient cache.Cache, logger *slog.Logger) error
SyncSeqFromDB synchronizes cache sequence counters with the database. For each distinct (scope, scopeID) pair in the updates table, it reads the max(seq) from the DB and sets the cache to max(max_seq, current_cache_seq). This prevents seq collisions when the cache is flushed or restarted.
Types ¶
type AgentRunner ¶
type AgentRunner interface {
}
AgentRunner runs agent queries. Implemented by internal/agent.Agent.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"` // "ok" or "degraded"
Components map[string]string `json:"components"` // e.g. "redis": "ok", "db": "error"
}
HealthResponse is the JSON response for the /healthz endpoint.
type Option ¶
Option is a function that configures the Server.
func WithAgent ¶
func WithAgent(a AgentRunner) Option
WithAgent sets the AgentRunner dependency (optional).
func WithConnectionManager ¶
func WithConnectionManager(cm *websocket.ConnectionManager) Option
WithConnectionManager sets the WebSocket ConnectionManager.
func WithLogLevel ¶
WithLogLevel sets the slog.LevelVar for runtime log level adjustment (optional).
func WithQueueManager ¶
WithQueueManager sets the queue.Manager dependency (optional).
func WithReadyFunc ¶
func WithReadyFunc(fn func()) Option
WithReadyFunc sets an optional callback invoked when the server is ready.
func WithSessionHandler ¶
func WithSessionHandler(h SessionDelegate) Option
WithSessionHandler sets the SessionDelegate dependency (optional).
func WithStatisticsStore ¶
func WithStatisticsStore(ss agent.StatisticsStore) Option
WithStatisticsStore sets the StatisticsStore dependency (optional).
func WithTelemetry ¶
WithTelemetry sets the Telemetry dependency (optional).
func WithWebhookStore ¶
WithWebhookStore sets the webhook.Store dependency (optional).
type SenderAdapter ¶
type SenderAdapter struct {
// contains filtered or unexported fields
}
SenderAdapter bridges the session handler's update methods to agent.UpdateDispatcher. It supports late-binding: the underlying session handler is set after construction to break the agent ↔ session circular dependency.
func NewSenderAdapter ¶
func NewSenderAdapter() *SenderAdapter
NewSenderAdapter creates a SenderAdapter with no backing session handler yet. Call SetSession before using the sender.
func (*SenderAdapter) SendPersistent ¶
func (a *SenderAdapter) SendPersistent(ctx context.Context, conversationID string, update agent.PersistentUpdate) error
SendPersistent sends a persistent update via the session handler.
func (*SenderAdapter) SendStreaming ¶
func (a *SenderAdapter) SendStreaming(ctx context.Context, conversationID string, chunk agent.StreamingChunk) error
SendStreaming sends a non-persistent streaming chunk via the session handler.
func (*SenderAdapter) SetSession ¶
func (a *SenderAdapter) SetSession(s SessionUpdateWriter)
SetSession sets the underlying session handler. Must be called before any Send.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds all application dependencies and HTTP infrastructure.
func NewServer ¶
NewServer creates a Server with the provided options. All required dependencies (Store, Cache, TaskQueue, Config, Logger) must be set.
type SessionDelegate ¶
type SessionDelegate interface {
HandleMessage(ctx context.Context, connID string, data []byte)
OnConnectionClose(ctx context.Context, connID string)
}
SessionDelegate handles WebSocket session messages. Implemented by internal/session.Handler.
type SessionUpdateWriter ¶
type SessionUpdateWriter interface {
SendNonPersistentUpdate(ctx context.Context, scope, scopeID, kind string, payload []byte) error
SendPersistentUpdate(ctx context.Context, scope, scopeID, kind string, payload []byte, convID string) (uint64, error)
}
SessionUpdateWriter is the interface the adapter needs from the session handler.