Documentation
¶
Overview ¶
Package server exposes the workspace to the browser front end.
It listens on the loopback interface only and requires a token that is generated per run and handed to the window in its URL, so nothing else on the machine can drive the agents through it.
Index ¶
- Variables
- func Probe(baseURL, token string) (*healthMsg, error)
- func RequestOpen(baseURL, token, path string) error
- func RequestQuit(baseURL, token string) error
- type Server
- func (s *Server) Addr() string
- func (s *Server) Attach()
- func (s *Server) BaseURL() string
- func (s *Server) ClientCount() int
- func (s *Server) Close() error
- func (s *Server) Detach()
- func (s *Server) Detached() bool
- func (s *Server) RefreshGitNow()
- func (s *Server) SetUpdate(u *UpdateView)
- func (s *Server) Token() string
- func (s *Server) URL() string
- func (s *Server) Update() *UpdateView
- func (s *Server) Wake()
- type UpdateView
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is reported by the health endpoint. main sets it at startup.
Functions ¶
func Probe ¶
Probe checks whether a recorded instance is alive and answering, and returns what it reports about itself.
An instance that answers but reports itself not ready is given a while: the caller's only other option is to declare the record stale and start a rival instance, which splits the agents in two and is much the worse mistake.
func RequestOpen ¶
RequestOpen asks a running instance to open a project.
func RequestQuit ¶
RequestQuit asks a running instance to shut down, and waits for it to have gone.
The instance answers as soon as it has accepted the request; stopping every agent and saving the layout comes after. Returning on the acceptance made `flockdeck -quit` say "stopped" while it was still going, and left the next launch racing it: a `flockdeck` typed straight afterwards would probe the instance on its way out, find it answering, and attach to a process that was about to exit -- ending up with a window onto nothing.
Types ¶
type Server ¶
type Server struct {
// OnLastClientGone is called when the final window closes, so the
// application can decide whether to shut down.
OnLastClientGone func()
// OnQuit is called when a shutdown is requested from the interface or by
// another launch of the binary.
OnQuit func()
// OnRestart is called when the interface asks to come back up on a newly
// downloaded version. It is separate from OnQuit because the shutdown has
// to know whether to start the program again once it has replaced it.
OnRestart func()
// contains filtered or unexported fields
}
Server serves the front end and the live connections behind it.
func (*Server) Attach ¶
func (s *Server) Attach()
Attach reverses a detach, so closing the window quits again.
func (*Server) BaseURL ¶
BaseURL is the address without the token, for the health and control endpoints a second launch uses.
func (*Server) ClientCount ¶
ClientCount reports how many windows are currently connected.
func (*Server) Detach ¶
func (s *Server) Detach()
Detach makes the application keep running after its last window closes, so the agents carry on and can be reattached to later.
func (*Server) RefreshGitNow ¶
func (s *Server) RefreshGitNow()
RefreshGitNow asks the git loop to re-examine the checkouts straight away. It is safe to call from any goroutine and never blocks; a request made while one is already pending is folded into it.
func (*Server) SetUpdate ¶
func (s *Server) SetUpdate(u *UpdateView)
SetUpdate records that a release has been staged and is ready to be applied by a restart, so the next snapshot tells the windows about it.
func (*Server) URL ¶
URL is the address the window should open, including the token that authorises it.
func (*Server) Update ¶
func (s *Server) Update() *UpdateView
Update returns the staged release, or nil when there is none.
type UpdateView ¶
type UpdateView struct {
Version string `json:"version"`
Notes string `json:"notes,omitempty"`
URL string `json:"url,omitempty"`
}
UpdateView is a downloaded release as the interface shows it.