Documentation ¶
Overview ¶
Package cmd implements utilities related to setting up command line applications in elasticsearch-asg.
Index ¶
- Constants
- func BuildPromFQName(subsystem, name string) string
- func GracefulShutdown(s *http.Server, timeout time.Duration) error
- func NewHealthchecksHandler(r prometheus.Registerer, appName string) healthcheck.Handler
- func SetGlobalLogger(logger *zap.Logger) func()
- func SetGlobalLoggerAt(logger *zap.Logger, stdLogLevel zapcore.Level) func()
- func WithInterrupt(ctx context.Context) (context.Context, context.CancelFunc)
- type AWSFlags
- type ElasticsearchFlags
- type Flagger
- type LoggingFlags
- type ServerFlags
Constants ¶
const Namespace = "elasticsearchasg"
Namespace is the namespace to be used for Prometheus metrics throughout elasticsearch-asg.
Variables ¶
This section is empty.
Functions ¶
func BuildPromFQName ¶
func GracefulShutdown ¶
GracefulShutdown shutsdown a server, giving open connections up to the timeout duration to close before forceably stopping the server. If timeout <= 0, the server will wait indefinitely for connections to close.
func NewHealthchecksHandler ¶
func NewHealthchecksHandler(r prometheus.Registerer, appName string) healthcheck.Handler
NewHealthchecksHandler returns a new healthcheck.Handler, configured with a basic liveness check and Prometheus healthcheck status metrics for a given app name.
func SetGlobalLogger ¶
SetGlobalLogger both sets the zap global logger, and redirects the output from the standard library's package-global logger to the supplied logger at the debug level. It returns a teardown function to reset the global loggers.
func SetGlobalLoggerAt ¶
SetGlobalLogger both sets the zap global logger, and redirects the output from the standard library's package-global logger to the supplied logger at the specified level. It returns a teardown function to reset the global loggers.
func WithInterrupt ¶
WithInterrupt returns a Context that will be canceled if a SIGINT or SIGTERM is received.
Types ¶
type AWSFlags ¶
type AWSFlags struct { // Name of AWS region to use. Region string // Name of a shared AWS credentials profile to use. Profile string // Max number of retries to attempt on connection error. MaxRetries int }
AWSFlags represents a set of flags for connecting to AWS.
func NewAWSFlags ¶
NewAWSFlags returns a new BaseFlags.
type ElasticsearchFlags ¶
type ElasticsearchFlags struct { // URL(s) of Elasticsearch nodes to connect to. URLs []*url.URL // Exponential backoff retries flags. Retry struct { // Initial backoff duration. Init time.Duration // Max backoff duration. Max time.Duration } }
ElasticsearchFlags represents a base set of flags for connecting to Elasticsearch.
func NewElasticsearchFlags ¶
func NewElasticsearchFlags(app Flagger, retryInit, retryMax time.Duration) *ElasticsearchFlags
NewElasticsearchFlags returns a new BaseFlags.
func (*ElasticsearchFlags) NewElasticsearchClient ¶
func (f *ElasticsearchFlags) NewElasticsearchClient(options ...elastic.ClientOptionFunc) (*elastic.Client, error)
NewElasticsearchClient returns a new Elasticsearch client configured with the URL and retry flag values, plus any other options passed in.
type Flagger ¶
type Flagger interface { Flag(name string, help string) *kingpin.FlagClause Arg(name string, help string) *kingpin.ArgClause }
Flagger defines command line flags and args. Examples: kingpin.Application and kingping.CmdClause.
type LoggingFlags ¶
LoggingFlags represents a set of flags for setting up logging.
func NewLoggingFlags ¶
func NewLoggingFlags(app Flagger, logLevel string) *LoggingFlags
NewLoggingFlags returns a new LoggingFlags.
func (*LoggingFlags) NewLogger ¶
func (f *LoggingFlags) NewLogger() *zap.Logger
NewLogger returns a new logger based on the LogLevel flag.
type ServerFlags ¶
type ServerFlags struct { Port uint16 // Port to serve health checks, Prometheus metrics, and anything else on. LivePath string // HTTP path to serve the liveness healthcheck at. ReadyPath string // HTTP path to serve the readiness healthcheck at. MetricsPath string // HTTP path to serve Prometheus metrics at. }
ServerFlags represents a set of flags for setting up a server with healthchecks and Prometheus metrics.
func NewServerFlags ¶
func NewServerFlags(app Flagger, port int) *ServerFlags
NewServerFlags returns a new ServerFlags.
func (*ServerFlags) ConfigureMux ¶
func (f *ServerFlags) ConfigureMux(mux *http.ServeMux, h healthcheck.Handler, g prometheus.Gatherer) *http.ServeMux
ConfigureMux sets a mux to serve healthchecks and Prometheus metrics based on the path flags in f.