Documentation ¶
Overview ¶
Package server implements a server for fleet deployment.
Index ¶
Constants ¶
const ( DefaultHostName = "localhost" // The hostname of the server. DefaultEnvironment = "development" // The default environment for the server. DefaultPort = 8080 // Port to receive requests: see IANA Port Numbers. DefaultProfPort = 0 // Profiler port to receive requests.* DefaultMaxProcs = 0 // Maximum number of computer processors to utilize.* DefaultEtcd2Endpoint = "0.0.0.0:2379" // Default address and port to etcd2 service. // Connections. TCPReadTimeout = 10 * time.Second TCPWriteTimeout = 10 * time.Second // Error messages. InvalidMediaType = "Invalid Content-Type or Accept header value." InvalidMethod = "Invalid Method for this route." InvalidBody = "Invalid body of text in request." InvalidJSONText = "Invalid JSON format in text of body in request." InvalidJSONAttribute = "Invalid - 'text' attribute in JSON not found." InvalidAuthorization = "Invalid authorization." InvalidQueryString = "Invalid query string." )
Variables ¶
This section is empty.
Functions ¶
func PrintUsageAndExit ¶
func PrintUsageAndExit()
PrintUsageAndExit is used to print out command line options.
func PrintVersionAndExit ¶
func PrintVersionAndExit()
PrintVersionAndExit prints the version of the server then exits.
Types ¶
type ClusterMachine ¶
type ClusterMachine struct { MachineID string `json:"machine"` // Machine ID IP string `json:"ip"` // IP address of the machine MetaData string `json:"metadata"` // Metadata and sub-cluster Units []*ClusterUnit `json:"units"` // List of units running under the machine }
ClusterMachine represents each coreOS instance in the cluster.
func NewClusterMachine ¶
func NewClusterMachine(machine string, ip string, metaData string) *ClusterMachine
NewClusterMachine is a factory function that returns a new instance of NewClusterMachine.
type ClusterStatus ¶
type ClusterStatus struct {
Machines []*ClusterMachine `json:"machines"`
}
ClusterStatus is the master header for info on the cluster.
func GetClusterInfo ¶
func GetClusterInfo(machineQuery string, unitQuery string) (*ClusterStatus, error)
GetClusterInfo returns a structure that represents the state of the cluster services.
func NewClusterStatus ¶
func NewClusterStatus() *ClusterStatus
NewClusterStatus is a factory function that returns a new instance of ClusterStatus.
type ClusterUnit ¶
type ClusterUnit struct { Unit string `json:"unit"` // The name of the unit being run. Hash string `json:"hash"` // ID of the unit being run. Active string `json:"active"` // Whether it's active. Load string `json:"load"` // Whether it's loaded. Sub string `json:"sub"` // Whether it's running. }
ClusterUnit represents a systemd unit being run on the machine.
func NewClusterUnit ¶
NewClusterUnit is a factory function that returns a new instance of NewClusterUnit.
type MachineSorter ¶
type MachineSorter struct { Machines []*ClusterMachine // contains filtered or unexported fields }
MachineSorter implements the Sort interface, sorting the changes within.
func NewMachineSorter ¶
func NewMachineSorter(less ...machineLessFunc) *MachineSorter
NewMachineSorter returns a Sorter that sorts using the less functions, in order.
func (*MachineSorter) Less ¶
func (ms *MachineSorter) Less(i, j int) bool
Less is part of sort.Interface.
func (*MachineSorter) Sort ¶
func (ms *MachineSorter) Sort(machines []*ClusterMachine)
Sort sorts the argument slice according to the less functions passed to OrderedBy.
func (*MachineSorter) Swap ¶
func (ms *MachineSorter) Swap(i, j int)
Swap is part of sort.Interface.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is used to perform filtering work on the request before the main controllers are called.
func (*Middleware) ServeHTTP ¶
func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the interface to accept requests so they can be filtered before handling by the server.
type Options ¶
type Options struct { Name string `json:"name"` // The name of the server. HostName string `json:"hostName"` // The hostname of the server. Domain string `json:"domain"` // The domain of the server. Environment string `json:"environment"` // The environment of the server (dev, stage, prod, etc). Port int `json:"port"` // The default port of the server. ProfPort int `json:"profPort"` // The profiler port of the server. Etcd2Endpoint string `json:"etcd2Endpoint"` // The IP address and port to the etcd2 service. DSN string `json:"-"` // The DSN login string to the database. MaxProcs int `json:"maxProcs"` // The maximum number of processor cores available. Debug bool `json:"debugEnabled"` // Is debugging enabled in the application or server. }
Options represents parameters that are passed to the application to be used in constructing the server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main structure that represents a server instance.
func (*Server) LogRequest ¶
LogRequest logs the http request information into the logger.
func (*Server) Shutdown ¶
func (s *Server) Shutdown()
Shutdown takes down the server gracefully back to an initialize state.
func (*Server) StartProfiler ¶
func (s *Server) StartProfiler()
StartProfiler is called to enable dynamic profiling.
type ServiceRequest ¶
type ServiceRequest struct { ServiceName string `json:"serviceName"` // The name of the service to deploy. Version string `json:"version"` // The version of the deploy. NumInstances int `json:"numInstances"` // The number of instances to deploy. ServiceTemplate string `json:"serviceTemplate"` // Source code for the unit template. Etcd2Keys map[string]string `json:"etcd2Keys"` // etcd2 keys to update. Suffix string `json:"-"` // A unique suffix for the new service. Domain string `json:"-"` // What domain this cluster is serving. Environment string `json:"-"` // The environment (dev, stage, prod, etc). DeployID string `json:"-"` // A UUID for the request and for this deploy. // contains filtered or unexported fields }
ServiceRequest is a struct used to demarshal requests for a deploy.
func NewServiceRequest ¶
func NewServiceRequest(name string, vers string, instances int, template string, keys map[string]string) *ServiceRequest
NewServiceRequest is a factory function that returns a ServiceRequest instance.
func (*ServiceRequest) Deploy ¶
func (r *ServiceRequest) Deploy()
Deploy is a go routine that attempts to update etcd2 and/or run fleetctl to start a service in coreOS.
type Status ¶
type Status struct { Start time.Time `json:"startTime"` // The start time of the server. RequestCount int64 `json:"requestCount"` // How many requests came in to the server. RequestBytes int64 `json:"requestBytes"` // Size of the requests in bytes. RouteStats map[string]map[string]int64 `json:"routeStats"` // How many requests/bytes came into each route. }
Status contains runtime statistics.
func NewStatus ¶
NewStatus is a factory function that returns a new instance of Status. options is an optional list of functions that initialize the structure
func (*Status) IncrRequestStats ¶
IncrRequestStats increments the stats totals for the server.
func (*Status) IncrRouteStats ¶
IncrRouteStats increments the stats totals for the route.
type UnitSorter ¶
type UnitSorter struct { Units []*ClusterUnit // contains filtered or unexported fields }
UnitSorter implements the Sort interface, sorting the changes within.
func NewUnitSorter ¶
func NewUnitSorter(less ...unitLessFunc) *UnitSorter
NewMachineSorter returns a Sorter that sorts using the less functions, in order.
func (*UnitSorter) Sort ¶
func (us *UnitSorter) Sort(units []*ClusterUnit)
Sort sorts the argument slice according to the less functions passed to OrderedBy.