Documentation
¶
Overview ¶
Copyright © 2021 Optable Technologies Inc. All rights reserved. See LICENSE for details.
Copyright © 2021 Optable Technologies Inc. All rights reserved. See LICENSE for details.
Copyright © 2021 Optable Technologies Inc. All rights reserved. See LICENSE for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var JSONLoader = &jsonLoader{}
Functions ¶
func LevelFromVerbosity ¶
LevelFromVerbosity takes a command-line `-v` stackable flag count, e.g. `-vv`, `-vvv` and transforms it into a sensible loglevel. The mapping is:
``: Warn `-v`: Info `-vv`: Debug `-vvv`: Trace
Types ¶
type ConfigDir ¶ added in v0.2.0
type ConfigDir struct {
// contains filtered or unexported fields
}
ConfigDir allows managing a multiple contextual configuration files. Each configuration is given a context name, e.g. `prod`, `staging`, `devel` and each stores a specific configuration.
func NewConfigDir ¶ added in v0.2.0
func NewConfigDir(path string, opts ...ConfigDirOption) (*ConfigDir, error)
NewConfigDir creates a ConfigDir at a given path.
type ConfigDirCli ¶ added in v0.2.0
type ConfigDirCli struct { ConfigDirFlag Config ConfigDirCmd `cmd:"config"` // contains filtered or unexported fields }
func (*ConfigDirCli) Get ¶ added in v0.2.0
func (c *ConfigDirCli) Get(cfg interface{}) error
func (*ConfigDirCli) KongInit ¶ added in v0.2.0
func (c *ConfigDirCli) KongInit(path string, options ...ConfigDirOption) kong.Option
func (*ConfigDirCli) Set ¶ added in v0.2.0
func (c *ConfigDirCli) Set(cfg interface{}, setCurrent bool) error
type ConfigDirCmd ¶ added in v0.2.0
type ConfigDirCmd struct { Use ConfigUseCmd `cmd:"use"` List ConfigListCmd `cmd:"list"` }
func (*ConfigDirCmd) BeforeResolve ¶ added in v0.2.0
func (u *ConfigDirCmd) BeforeResolve(c *ConfigDirCli) (err error)
func (*ConfigDirCmd) Help ¶ added in v0.2.0
func (u *ConfigDirCmd) Help() string
type ConfigDirFlag ¶ added in v0.2.0
type ConfigDirFlag struct {
Config string `opt:""`
}
func (*ConfigDirFlag) BeforeResolve ¶ added in v0.2.0
func (f *ConfigDirFlag) BeforeResolve(c *ConfigDirCli) (err error)
func (*ConfigDirFlag) Help ¶ added in v0.2.0
func (f *ConfigDirFlag) Help() string
type ConfigDirOption ¶ added in v0.2.0
type ConfigDirOption interface {
// contains filtered or unexported methods
}
func WithConfigDirLoader ¶ added in v0.2.0
func WithConfigDirLoader(loader ConfigLoader) ConfigDirOption
func WithXdgConfigPath ¶ added in v0.2.0
func WithXdgConfigPath(configPath string) ConfigDirOption
type ConfigListCmd ¶ added in v0.2.0
type ConfigListCmd struct { }
func (*ConfigListCmd) BeforeResolve ¶ added in v0.2.0
func (u *ConfigListCmd) BeforeResolve(c *ConfigDirCli) (err error)
func (*ConfigListCmd) Run ¶ added in v0.2.0
func (u *ConfigListCmd) Run(c *ConfigDirCli) error
type ConfigLoader ¶ added in v0.2.0
type ConfigUseCmd ¶ added in v0.2.0
type ConfigUseCmd struct {
Name string `arg:"" placeholder:"<name>"`
}
func (*ConfigUseCmd) BeforeResolve ¶ added in v0.2.0
func (u *ConfigUseCmd) BeforeResolve(c *ConfigDirCli) (err error)
func (*ConfigUseCmd) Run ¶ added in v0.2.0
func (u *ConfigUseCmd) Run(c *ConfigDirCli) error
type ProfilingFlag ¶ added in v0.2.0
type ProfilingFlag struct {
Profiling string `opt:"" hidden:"true" default:""`
}
Profiling is a struct that can be embedded in any kong cli to enable easy and convenient profiling for performance analysis. The flag is hidden from the help message such that we can use it in public cli.
The supported values are:
- "cpu": Enables CPU profiling.
- "memory": Enables heap memory profiling.
- "block": Enables block (contention) profiling.
- "mutex": Enables mutex profiling.
- "trace": Enables trace profiling.
The profiling file path will be shown to stderr and can be opened with `go tool pprof $file` or `go tool pprof -http localhost:8080 $file`
In order to enable profiling, one should use the command like this: ``` stopProfiling := cli.Profiling.Start() defer stopProfiling() ```
func (*ProfilingFlag) Start ¶ added in v0.2.0
func (p *ProfilingFlag) Start() func()
Start starts the profiling operation. It returns a function that needs to be called when the profiling should stop.