server

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Instruction Instruction
	Data        string
}

Command from user to the App.

type Instruction

type Instruction int

Instruction from user to the App.

const (
	Pause Instruction = iota
	Resume
	RunTests
)

type Option

type Option func(*Server)

Option configures a Server.

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger configures Server with a logger.

type Server

type Server struct {
	Commands chan *Command
	// contains filtered or unexported fields
}

Server for serving web UI and API.

func New

func New(ctx context.Context, rootDir string, opts ...Option) *Server

New Server for serving web UI and API.

func (*Server) AddResult

func (s *Server) AddResult(r *runner.Result)

AddResult to be served via the API.

Prepends the result to the internal result slice. Slice is trimmed if its length exceeds configured max results.

func (*Server) Close

func (s *Server) Close() error

Close server.

func (*Server) Reset

func (s *Server) Reset()

Reset server to initial state.

Sets the state to state.Init, clears results, and closes all long poll subscriptions.

Note: This is mainly used for testing purposes.

func (*Server) SendNotification

func (s *Server) SendNotification(kind, bodyFmt string, args ...any)

SendNotification to display as a toaster message in the web UI.

func (*Server) Serve

func (s *Server) Serve(host string, port int) error

Serve requests on host and port.

func (*Server) SetState

func (s *Server) SetState(newState state.State)

SetState for server.

Jump to

Keyboard shortcuts

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