server

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeprecatedRoute

func DeprecatedRoute(msg string) func(http.HandlerFunc) http.HandlerFunc

func Start

func Start()

Types

type BoxStore

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

BoxStore provides thread-safe access to boxes

func (*BoxStore) Add

func (bs *BoxStore) Add(box api.Box) error

Add adds a new box (thread-safe write)

func (*BoxStore) Delete

func (bs *BoxStore) Delete(id string) (found bool, deletedBox api.Box)

Delete removes a box by ID (thread-safe write)

func (*BoxStore) Exists

func (bs *BoxStore) Exists(id string) bool

Exists checks if a box with given ID exists (thread-safe read)

func (*BoxStore) FindIndexByID

func (bs *BoxStore) FindIndexByID(id string) (int, error)

FindIndexByID returns the index of a box by ID (thread-safe read)

func (*BoxStore) ForEach

func (bs *BoxStore) ForEach(fn func(api.Box) bool)

ForEach iterates over all boxes with a read lock

func (*BoxStore) GetAll

func (bs *BoxStore) GetAll() []api.Box

GetAll returns a copy of all boxes (thread-safe read)

func (*BoxStore) GetByID

func (bs *BoxStore) GetByID(id string) (*api.Box, error)

GetByID returns a copy of a box by ID (thread-safe read)

func (*BoxStore) Len

func (bs *BoxStore) Len() int

Len returns the number of boxes (thread-safe read)

func (*BoxStore) Update

func (bs *BoxStore) Update(id string, updateFn func(*api.Box)) error

Update modifies an existing box (thread-safe write)

type Broker

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

Broker which will be created in this program. It is responsible for keeping a list of which clients (browsers) are currently attached and broadcasting events (messages) to those clients.

func (*Broker) ClientCount

func (b *Broker) ClientCount() int

ClientCount returns the current number of connected clients (thread-safe)

func (*Broker) ServeHTTP

func (b *Broker) ServeHTTP(w http.ResponseWriter, r *http.Request)

This Broker method handles and HTTP request at the "/events/" URL.

func (*Broker) Start

func (b *Broker) Start(ctx context.Context)

Start method, this Broker method starts a new goroutine. It handles the addition & removal of clients, as well as the broadcasting of messages out to clients that are currently attached.

type Options

type Options struct {
	ApiPort       string `long:"api-port" description:"The port to use for api calls" default:"8081"`
	SitePort      string `short:"p" long:"port" description:"The port to use for the dashboard" default:"8080"`
	Debug         bool   `long:"debug" description:"Print debug messages"`
	Demo          bool   `long:"run-demo" description:"Run a demo, will use temporary folder"`
	DefaultStatic bool   `long:"default-static" description:"Use default static content"`
	DataPath      string `short:"d" long:"data-path" description:"Path to store data files (default: $HOME/.alive/data)"`
	StaticPath    string `long:"static-path" description:"Path to store static files (default: $HOME/.alive/static)"`
	ParentUrl     string `` /* 143-byte string literal not displayed */
	ParentBoxID   string `long:"parent-id" description:"Box id to use when updating status on a parent dashboard"`
	ParentBoxSize string `long:"parent-size" description:"Box size to use when updating status on a parent dashboard (default: large)" default:"large"`
}

Jump to

Keyboard shortcuts

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