server

package
v0.0.0-...-8cfe5f7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package server describes all server-side operations.

Package server describes all server-side operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRunning

func IsRunning(conf *config.Opts) (bool, error)

Check whether the server is running.

func RegisterOperation

func RegisterOperation(name string, operation Operation)

func Run

func Run(conf *config.Opts) error

Start server operation. This function will block until server shutdown.

func StartInBackground

func StartInBackground(conf *config.Opts) (int, error)

TODO: Move to client package? Start a server in a background process.

Types

type Notification

type Notification struct {
	Task  string    `json:"task"`  // The name of the task; empty if idle
	Since time.Time `json:"since"` // Time of the last status change, formatted
}

The notification to send to listeners.

func TaskNotification

func TaskNotification(t msg.Task) Notification

A notification about a task, presumed to be the currently set one. If the task has been stopped, it sends an empty task name, signalling idle state.

type NotificationListener

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

An entity awaiting notifications about task changes.

func (*NotificationListener) Notify

func (lst *NotificationListener) Notify(ntf Notification) error

Notify this listener.

type Operation

type Operation interface {
	// Execute server-side behaviour based on the command
	ServerExec(srv *Server, req *Request) error
}

type Request

type Request struct {
	Conn net.Conn
	Cmd  msg.Cmd
}

func (*Request) Close

func (req *Request) Close() error

type Server

type Server struct {
	Backend backend.Backend // The database backend

	CurrentTask msg.Task // The currently active task, if any
	// contains filtered or unexported fields
}

A tilo Server. When the configuration is provided, the remaining fields are filled by the .init() method.

func (*Server) Answer

func (s *Server) Answer(req *Request, resp msg.Response) error

Answer the request with the provided response.

func (*Server) Dispatch

func (s *Server) Dispatch(req *Request) error

func (*Server) InitiateShutdown

func (s *Server) InitiateShutdown()

Initiate the server to shut down, accepting no further connections.

func (*Server) RegisterListener

func (s *Server) RegisterListener(req *Request) (NotificationListener, error)

Register the listener with the server. If it cannot be notified immediately, an error is returned.

func (*Server) SaveTask

func (s *Server) SaveTask(task msg.Task) error

Save a task to the backend database.

func (*Server) SetActiveTask

func (s *Server) SetActiveTask(taskName string)

Change the server's current task.

func (*Server) StopCurrentTask

func (s *Server) StopCurrentTask() (msg.Task, bool)

Stop the current task and return it. Returns true if the task was actually halted and false if it had been stopped before this function was called.

Directories

Path Synopsis
Package backend describes possible database backends for the server.
Package backend describes possible database backends for the server.
sqlite3
SQLite3 backend for the tilo server.
SQLite3 backend for the tilo server.

Jump to

Keyboard shortcuts

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