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 ¶
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 Request ¶
type Request struct { HttpMethod string Handler string Path string Body []byte Headers map[string][]string PathParams map[string]string QueryParams map[string][]string }
This is just a wrapper around the protobuf definition in proto/ingress.proto It makes them easier to use and avoids exposing the generated code to the rest of the runtime package.
type Response ¶
This is just a wrapper around the protobuf definition in proto/ingress.proto It makes them easier to use and avoids exposing the generated code to the rest of the runtime package.
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
This struct is basically about managing all 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) GetManifest ¶
func (s *Supervisor) GetManifest() (*manifest.Manifest, error)
func (*Supervisor) Restart ¶
func (s *Supervisor) Restart() error
func (*Supervisor) Start ¶
func (s *Supervisor) Start() error
func (*Supervisor) Stop ¶
func (s *Supervisor) Stop() error