supervisor

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package subprocess offers a simple way to manage a subprocess. Its concern is starting, stopping, handling stdin/out... that kind of thing.

Package service is responsible for the management of a single service, defined by the user. It does this through the management of a subprocess, which is running an application defined with the fold sdk.

It exposes a simple RPC based interface for interacting with that subprocess which can be used by the handlers as they wish. Communication between the runtime and the subprocess is done via gRPC over a unix domain socket.

This approach was chosen because it results in very little overhead (it adds a few milliseconds to startup time and a few hundred microseconds to each request) and because it allows us to generate much of the code for both sides. This will make it very easy to implement the sdk in multiple languages.

Index

Constants

This section is empty.

Variables

View Source
var (
	FailedToStartProcess  = errors.New("failed to start subprocess")
	FailedToStopProcess   = errors.New("failed to stop subprocess")
	FailedToSignalProcess = errors.New("failed to signal subprocess")
	CannotServiceRequest  = []byte(
		`{"title": "Cannot service request","detail":"The application is not running. Please check the logs."}`,
	)
)

Functions

This section is empty.

Types

type Supervisor

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

TODO This can all be greatly improved really. What we're trying to do is manage the different states for a client and subprocess. States -> Action:

  • process: up, client: up -> Do Request
  • process: up, client: down -> Error Response
  • process: down, client: up -> Error Response
  • process: down, client: down -> Error Response

This essentially boils down to two states - Available and NotAvailable. The Available state can only be reached by succesfully calling the Start method - which means that both the process and client have been started succesfully. In all states the process should remain available for restart. Setting the state will need to be synchronised as this is shared by the router which can potentially issue multiple request at once.

func NewSupervisor

func NewSupervisor(logger logging.Logger, cmd string, args ...string) *Supervisor

func (*Supervisor) DoRequest

func (s *Supervisor) DoRequest(req *types.Request) (*types.Response, error)

func (*Supervisor) GetManifest

func (s *Supervisor) GetManifest() (*manifest.Manifest, error)

func (*Supervisor) Restart

func (s *Supervisor) Restart() error

func (*Supervisor) Signal

func (s *Supervisor) Signal(sig os.Signal) error

func (*Supervisor) Start

func (s *Supervisor) Start() error

func (*Supervisor) Stop

func (s *Supervisor) Stop() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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