server

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package server exposes claumeter's parsed usage over a small HTTP API. Widgets (waybar, eww, sketchybar, …) and dashboards consume these endpoints instead of re-parsing the JSONL transcripts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker fan-outs a single message to N SSE subscribers. Slow subscribers have their message dropped rather than blocking the publisher.

func NewBroker

func NewBroker() *Broker

func (*Broker) Count

func (b *Broker) Count() int

func (*Broker) Publish

func (b *Broker) Publish(msg []byte)

func (*Broker) Subscribe

func (b *Broker) Subscribe() chan []byte

func (*Broker) Unsubscribe

func (b *Broker) Unsubscribe(ch chan []byte)

type Options

type Options struct {
	Root    string
	Addr    string // e.g. "127.0.0.1:7777"
	Token   string // optional bearer; empty = open
	Version string // passed into /healthz
}

Options configures a Server.

type Server

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

func New

func New(opts Options) (*Server, error)

func NewWithStore

func NewWithStore(opts Options, store *Store) *Server

func (*Server) Broker

func (s *Server) Broker() *Broker

func (*Server) ListenAndServe

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

ListenAndServe runs until the context is cancelled or the server errors.

func (*Server) PublishToday

func (s *Server) PublishToday()

PublishToday computes a fresh `today` payload and pushes it to SSE subscribers. Called by the file-watch feeder after a reload.

func (*Server) Store

func (s *Server) Store() *Store

type Store

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

Store caches parsed usage data and lets handlers query it without touching the filesystem on every request. Reload() refreshes it.

func NewStore

func NewStore(root string) (*Store, error)

func (*Store) Data

func (s *Store) Data() usage.Data

func (*Store) Reload

func (s *Store) Reload() error

func (*Store) Root

func (s *Store) Root() string

Jump to

Keyboard shortcuts

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