Documentation ¶
Overview ¶
Package control provides a HTTP server listening on the unix domain socket for use as a control plane, as well as all the HTTP endpoints.
Index ¶
- Variables
- func GetPing(w http.ResponseWriter, r *http.Request)
- type Config
- type Endpoints
- func (e Endpoints) PostDisableMaintenanceMode(r *http.Request) (interface{}, int)
- func (e Endpoints) PostEnableMaintenanceMode(r *http.Request) (interface{}, int)
- func (e Endpoints) PostMetric(r *http.Request) (interface{}, int)
- func (e Endpoints) PostReload(r *http.Request) (interface{}, int)
- func (e Endpoints) PutEnviron(r *http.Request) (interface{}, int)
- type HTTPServer
- type PostHandler
Constants ¶
This section is empty.
Variables ¶
var ( SocketType = "unix" ErrMissingAddr = errors.New("control server not loading due to missing config") )
SocketType is the default listener type
var DefaultSocket = "/var/run/containerpilot.socket"
DefaultSocket is the default location of the unix domain socket file
Functions ¶
Types ¶
type Config ¶
type Config struct {
SocketPath string `mapstructure:"socket"`
}
Config represents the location on the file system which serves the Unix control socket file.
type Endpoints ¶
type Endpoints struct {
// contains filtered or unexported fields
}
Endpoints wraps the EventBus so we can bridge data across the App and HTTPServer API boundary
func (Endpoints) PostDisableMaintenanceMode ¶
PostDisableMaintenanceMode handles incoming HTTP POST requests and toggles ContainerPilot maintenance mode on. Returns empty response or HTTP422.
func (Endpoints) PostEnableMaintenanceMode ¶
PostEnableMaintenanceMode handles incoming HTTP POST requests and toggles ContainerPilot maintenance mode on. Returns empty response or HTTP422.
func (Endpoints) PostMetric ¶
PostMetric handles incoming HTTP POST requests, serializes the metrics into Events, and publishes them for sensors to record their values. Returns empty response or HTTP422.
func (Endpoints) PostReload ¶
PostReload handles incoming HTTP POST requests and reloads our current ContainerPilot process configuration. Returns empty response or HTTP422.
type HTTPServer ¶
HTTPServer contains the state of the HTTP Server used by ContainerPilot's HTTP transport control plane. Currently this is listening via a UNIX socket file.
func NewHTTPServer ¶
func NewHTTPServer(cfg *Config) (*HTTPServer, error)
NewHTTPServer initializes a new control server for manipulating ContainerPilot's runtime configuration.
func (*HTTPServer) Run ¶
func (srv *HTTPServer) Run(pctx context.Context, bus *events.EventBus)
Run executes the event loop for the control server
func (*HTTPServer) Start ¶
func (srv *HTTPServer) Start(cancel context.CancelFunc)
Start sets up API routes with the event bus, listens on the control socket, and serves the HTTP server.
func (*HTTPServer) Stop ¶
func (srv *HTTPServer) Stop() error
Stop shuts down the control server gracefully
func (*HTTPServer) Validate ¶
func (srv *HTTPServer) Validate() error
Validate validates the state of the control server and ensures that the socket does not exist prior to setting up the listener (bind).
type PostHandler ¶
PostHandler is an adapter which allows a normal function to serve itself and handle incoming HTTP POST requests, and allows us to pass thru EventBus to handlers
func (PostHandler) ServeHTTP ¶
func (pw PostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)