server

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server provides functionality to serve Starlark over HTTP. It has functionality to watch a file and hot reload the browser on changes.

func NewServer

func NewServer(host string, port int, watch bool, path string, maxDuration int, timeout int, serveGif bool) (*Server, error)

NewServer creates a new server initialized with the applet.

func (*Server) Run

func (s *Server) Run() error

Run serves the http server and runs forever in a blocking fashion.

type Watcher added in v0.32.0

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

Watcher is a structure to watch a file for changes and notify a channel.

func NewWatcher added in v0.32.0

func NewWatcher(filename string, fileChanges chan bool) *Watcher

NewWatcher instantiates a new watcher with the provided filename and changes channel.

func (*Watcher) Run added in v0.32.0

func (w *Watcher) Run() error

Run starts the file watcher in a blocking fashion. This watches an entire directory and only notifies the channel when the specified file is changed. If there is an error, it's returned. It's up to the caller to respawn the watcher if it's desireable to keep watching.

The reason it watches a directory is becausde some editors like VIM write to a swap file and recreate the original file. So we can't simply watch the original file, we have to watch the directory. This is also why we check both the WRITE and CREATE events since VIM will write to a swap and then create the file on save. VSCode does a WRITE and then a CHMOD, so tracking WRITE catches the changes for VSCode exactly once.

Directories

Path Synopsis
Package browser provides the ability to send images to a browser over websockets.
Package browser provides the ability to send images to a browser over websockets.
Package loader provides primitives to load an applet both when the underlying file changes and on demand when an update is requested.
Package loader provides primitives to load an applet both when the underlying file changes and on demand when an update is requested.

Jump to

Keyboard shortcuts

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