Documentation
¶
Overview ¶
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func CreateDefaultRouterGroup(router *routing.Router) *routing.RouteGroup
- func DurationToMillis(duration time.Duration) float64
- func Uname(buf *UnameInfo) (err error)
- type BuildInfo
- type ConfigSourceFunc
- type GoodToGoFunc
- type HealthCheckFunc
- type HealthCheckReport
- type HealthCheckResult
- type ReportDuration
- type ServiceCanaryFunc
- type StandardEndpoints
- func (s *StandardEndpoints) RegisterDefaultEndpoints(router *routing.Router)
- func (s *StandardEndpoints) RegisterEndpoints(group *routing.RouteGroup)
- func (s *StandardEndpoints) SetConfigSourceFunc(configSrc ConfigSourceFunc)
- func (s *StandardEndpoints) SetGoodToGoFunc(gtgCheck GoodToGoFunc)
- func (s *StandardEndpoints) SetHealthCheckFuncs(interval time.Duration, healthchecks ...HealthCheckFunc)
- func (s *StandardEndpoints) SetServiceCanaryFunc(canaryCheck ServiceCanaryFunc)
- type Status
- type TextPlainDataWriter
- type UnameInfo
Constants ¶
const ( HealthResultNotRun = "not_run" HealthResultRunning = "running" HealthResultPassed = "passed" HealthResultFailed = "failed" )
HealthResult "not_run", "running", "passed", "failed"
const (
MIME_TEXT_PLAIN = "text/plain"
)
Variables ¶
var (
DefaultHealthCheckInterval = time.Duration(10) * time.Second
)
Functions ¶
func CreateDefaultRouterGroup ¶
func CreateDefaultRouterGroup(router *routing.Router) *routing.RouteGroup
func DurationToMillis ¶
Types ¶
type BuildInfo ¶
type BuildInfo struct {
ArtifactID string `json:"artifact_id"`
BuildNumber string `json:"build_number"`
BuildMachine string `json:"build_machine"`
BuiltBy string `json:"built_by"`
BuiltWhen string `json:"built_when"`
// VCS (baked in)
GitSha1 string `json:"git_sha1"`
GitBranch string `json:"git_branch"` // ADDITIONAL -
GitRepo string `json:"git_repo"` // ADDITIONAL -
// runbook (baked in)
RunbookURI string `json:"runbook_uri"`
// version number (baked in)
Version string `json:"version"`
}
these should be provided by the application
type ConfigSourceFunc ¶
type ConfigSourceFunc func() interface{}
ConfigSourceFunc returns the configuration that is used by the service
func ToConfigSourceFunc ¶
func ToConfigSourceFunc(config interface{}) ConfigSourceFunc
type GoodToGoFunc ¶
type GoodToGoFunc func() bool
The "Good To Go" (GTG) returns a successful response in the case that the service is in an operational state and is able to receive traffic.
type HealthCheckFunc ¶
type HealthCheckFunc func() HealthCheckResult
Healthcheck resource provides information about internal health and its perceived health of downstream dependencies.
type HealthCheckReport ¶
type HealthCheckReport struct {
Timestamp time.Time `json:"report_as_of"` // The time at which this report was generated (this may not be the current time)
Duration ReportDuration `json:"report_duration"` // How long it took to generate the report
Results []HealthCheckResult `json:"tests"` // array of test results
}
type HealthCheckResult ¶
type HealthCheckResult struct {
// To convert Duration use: DurationToMillis(..)
DurationMillis float64 `json:"duration_millis"` // Number of milliseconds taken to run the test
Name string `json:"test_name"` // The name of the test, a name that is meaningful to supporting engineers
Result string `json:"test_result"` // The state of the test, may be "not_run", "running", "passed", "failed"
Timestamp time.Time `json:"tested_at"` // The time at which this test was executed
}
type ReportDuration ¶
func (ReportDuration) MarshalJSON ¶
func (r ReportDuration) MarshalJSON() ([]byte, error)
type ServiceCanaryFunc ¶
type ServiceCanaryFunc func() bool
The "Service Canary" (ASG) returns a successful response in the case that the service is in a healthy state.
type StandardEndpoints ¶
type StandardEndpoints struct {
Status *Status
// contains filtered or unexported fields
}
func NewStandardEndpoints ¶
func NewStandardEndpoints() *StandardEndpoints
func NewStandardEndpointsWithBuildInfo ¶
func NewStandardEndpointsWithBuildInfo(buildInfo *BuildInfo) *StandardEndpoints
func (*StandardEndpoints) RegisterDefaultEndpoints ¶
func (s *StandardEndpoints) RegisterDefaultEndpoints(router *routing.Router)
func (*StandardEndpoints) RegisterEndpoints ¶
func (s *StandardEndpoints) RegisterEndpoints(group *routing.RouteGroup)
func (*StandardEndpoints) SetConfigSourceFunc ¶
func (s *StandardEndpoints) SetConfigSourceFunc(configSrc ConfigSourceFunc)
func (*StandardEndpoints) SetGoodToGoFunc ¶
func (s *StandardEndpoints) SetGoodToGoFunc(gtgCheck GoodToGoFunc)
func (*StandardEndpoints) SetHealthCheckFuncs ¶
func (s *StandardEndpoints) SetHealthCheckFuncs(interval time.Duration, healthchecks ...HealthCheckFunc)
Set the health check functions to run at a specified interval
func (*StandardEndpoints) SetServiceCanaryFunc ¶
func (s *StandardEndpoints) SetServiceCanaryFunc(canaryCheck ServiceCanaryFunc)
type Status ¶
type Status struct {
// Build info (baked in)
BuildInfo
CompilerVersion string `json:"compiler_version"` // optional
// per request
CurrentTime string `json:"current_time"` // dynamic - per req
// maven group
GroupID string `json:"group_id"` // N/A - maven
// machine (baked in)
MachineName string `json:"machine_name"` // dynamic
OSArch string `json:"os_arch"` // dynamic
OSAvgload string `json:"os_avgload"` // dynamic - per req
OSName string `json:"os_name"` // dynamic
OSNumProcessor string `json:"os_numprocessors"` // dynamic
OSVersion string `json:"os_version"` // dynamic
// dynamic / at startup
UpDuration string `json:"up_duration"` // dynamic - per req
UpSince string `json:"up_since"` // at startup
// N/A
VMName string `json:"vm_name"` // N/A
VMVendor string `json:"vm_vendor"` // N/A
VMVersion string `json:"vm_version"` // N/A
// go additions
GoMaxProcs string `json:"go_maxprocs"` // ADDITIONAL -
GoNumRoutines string `json:"go_numroutines"` // ADDITIONAL - dynamic
UpSinceTime time.Time `json:"-"`
}
type TextPlainDataWriter ¶
type TextPlainDataWriter struct{}
func (*TextPlainDataWriter) SetHeader ¶
func (w *TextPlainDataWriter) SetHeader(res http.ResponseWriter)
func (*TextPlainDataWriter) Write ¶
func (w *TextPlainDataWriter) Write(res http.ResponseWriter, data interface{}) error