server

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 22 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindPort

func FindPort(startPort int) (string, error)

FindPort tries to listen on startPort, incrementing up to 10 times if busy. Returns the addr string "127.0.0.1:PORT" that succeeded, or an error.

Types

type LoopStateProvider

type LoopStateProvider interface {
	State() loop.LoopState
}

type Options

type Options struct {
	RuntimeDir        string
	Addr              string // host:port, defaults to "127.0.0.1:0"
	Now               func() time.Time
	UI                fs.FS          // embedded SPA assets; nil = placeholder only
	Config            *config.Config // project config; nil = zero config
	LoopStateProvider LoopStateProvider
	Warnings          []string
	Broker            *SessionEventBroker
}

Options configures the HTTP server.

type Server

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

Server serves the web UI API.

func New

func New(opts Options) *Server

New creates a Server but does not start it.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the listener address. Only valid after Start begins.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start begins listening and serving. It starts the SSE file watcher in the background. Blocks until the server shuts down.

func (*Server) WaitReady

func (s *Server) WaitReady()

WaitReady blocks until the server is listening.

type SessionEventBroker

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

SessionEventBroker implements dispatcher.SessionEventSink. Fans out session events to subscribed WebSocket clients.

func NewSessionEventBroker

func NewSessionEventBroker() *SessionEventBroker

func (*SessionEventBroker) PublishSessionDelta

func (b *SessionEventBroker) PublishSessionDelta(sessionID string, text string, ts time.Time)

PublishSessionDelta broadcasts an ephemeral text delta to subscribers.

func (*SessionEventBroker) PublishSessionEvent

func (b *SessionEventBroker) PublishSessionEvent(sessionID string, ev event.Event)

PublishSessionEvent implements dispatcher.SessionEventSink. Converts event.Event -> EventLine, serializes, fans out.

func (*SessionEventBroker) Subscribe

func (b *SessionEventBroker) Subscribe(sessionID string, sub Subscriber)

func (*SessionEventBroker) Unsubscribe

func (b *SessionEventBroker) Unsubscribe(sessionID string, sub Subscriber)

func (*SessionEventBroker) UnsubscribeAll

func (b *SessionEventBroker) UnsubscribeAll(sub Subscriber)

type Subscriber

type Subscriber interface {
	Send(msg []byte) bool // false if client is slow/dead
	Close()               // disconnect the client
}

Subscriber receives serialized messages. Decoupled from wsClient.

Jump to

Keyboard shortcuts

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