Documentation ¶
Overview ¶
Package server implements a server for artifactory monitoring.
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.* DefaultPollingInterval = 300 // Polling interval in seconds to check artifactory (5 min). // 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." )
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 ArtFolderInfo ¶
type ArtFolderInfo struct { Repo string `json:"repo"` // The repository being queried. Path string `json:"path"` // The file path in the repo. Created string `json:"created"` // When the folder or file was created. CreatedBy string `json:"createdBy"` // Who created the folder or file. LastModified string `json:"lastModified"` // When was the folder or file last modified. ModifiedBy string `json:"modifiedBy"` // Who modified the folder or file. LastUpdated string `json:"lastUpdated"` // This might be the same as last modified? Children []*ArtFolderInfoChild `json:"children"` // This is a list of folders and files in the directory. Uri string `json:"uri"` // The API URL that was called. }
ArtFolderInfo is returned from a call to collect folder info from an API request.
type ArtFolderInfoChild ¶
type ArtFolderInfoChild struct { Uri string `json:"uri"` // The subdirectory or file name ex: "/1.0.0-21" Folder bool `json:"folder"` // If true, this is a subdirectory. }
ArtFolderInfoChild is returned from a call to collect folder info from an API request. See ArtFolderInfo.
type DeployWorker ¶
type DeployWorker struct { Name string `json:"name"` // The image name to deploy. Version string `json:"version"` // The version to deploy. Opts *Options `json:"options"` // Server options. DeployID string `json:"deployID"` // A UUID returned from the deploy. // contains filtered or unexported fields }
DeployWorker is a struct used to manage the deploy job to the cluster.
func NewDeployWorker ¶
func NewDeployWorker(name string, version string, o *Options, l *logger.Logger, d *db.DBConnect, w *sync.WaitGroup) *DeployWorker
NewDeployWorker is a factory function that returns a DeployWorker instance.
func (*DeployWorker) Run ¶
func (d *DeployWorker) Run()
Run is a go routine that performs the deploy job actions.
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). DeployURL string `json:"deployURL"` // The coreos-deploy url endpoint. DeployToken string `json:"-"` // The coreos-deploy token for security access. ArtAPIEndpoint string `json:"artAPIEndpoint"` // The artifactory API endpoint. ArtUserID string `json:"-"` // The artifactory user id. ArtPassword string `json:"-"` // The artifactory password. ArtPollingInterval int `json:"artPollingInterval"` // The artifactory polling interval in seconds. ArtDeployRepo string `json:"artDeployRepo"` // The artifactory repo of the deploy request files. ArtPayloadRepo string `json:"artPayloadRepo"` // The artifactory repo of the deployment payloads. Port int `json:"port"` // The default port of the server. ProfPort int `json:"profPort"` // The profiler port of the server. 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) Monitor ¶
func (s *Server) Monitor()
Monitor is a go routine that continually monitors artifactory for any version changes.
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 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.