Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptySrc = fmt.Errorf("empty src template")
ErrEmptySrc is returned if an emty src template is passed to NewResource
Functions ¶
func RegisterCustomJsFilters ¶ added in v0.10.0
RegisterCustomJsFilters loads all filters from the given directory. It returns an error if any.
Types ¶
type Backend ¶
type Backend struct {
easykv.ReadWatcher
// Name is the name of the backend for example etcd or consul.
// The name is attached to the logs.
Name string
// Onetime - render the config file and quit.
Onetime bool
// Enable/Disable watch support.
Watch bool
// Watch only these keys
WatchKeys []string
// The key-path prefix.
Prefix string
// The backend polling interval. Can be used as a reconciliation loop for watch or standalone.
Interval int
// The backend keys that the template requires to be rendered correctly.
Keys []string
// contains filtered or unexported fields
}
Backend is the representation of a template backend like etcd or consul
type BackendConnector ¶
A BackendConnector - Every backend implements this interface.
If Connect is called a new connection to the underlaying kv-store will be established.
Connect should also set the name and the StoreClient of the Backend. The other values of Backend will be loaded from the configuration file.
type ExecConfig ¶
type ExecConfig struct {
// Command is the command to execute. // Backtick parsing is supported:
// ./foo `echo $SHELL`
Command string `json:"command"`
// ReloadSignal is the Signal that is sended to the subpocess if we want to reload it.
// If no signal is specified the child process will be killed (gracefully) and started again.
ReloadSignal string `toml:"reload_signal" json:"reload_signal"`
// KillSignal defines the signal sent to the child process when remco is gracefully shutting down.
//
// The application needs to exit before the kill_timeout, it will be terminated otherwise (like kill -9).
// The default value is “SIGTERM”.
KillSignal string `toml:"kill_signal" json:"kill_signal"`
// KillTimeout - the maximum amount of time in seconds to wait for the child process to gracefully terminate.
KillTimeout int `toml:"kill_timeout" json:"kill_timeout"`
// A random splay to wait before killing the command.
// May be useful in large clusters to prevent all child processes to reload at the same time when configuration changes occur.
Splay int `json:"splay"`
}
ExecConfig represents the configuration values for the exec mode.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
An Executor controls a subprocess. It can control the whole process lifecycle and can reload and stop the process gracefully or send other signals to the child process using channels.
func NewExecutor ¶
func NewExecutor(execCommand, reloadSignal, killSignal string, killTimeout, splay int, logger hclog.Logger) Executor
NewExecutor creates a new Executor.
func (*Executor) Reload ¶
Reload reloads the child process. If a reloadSignal is provided it will send this signal to the child. The child process will be killed and restarted otherwise.
func (*Executor) SignalChild ¶
SignalChild forwards the os.Signal to the child process.
func (*Executor) SpawnChild ¶
SpawnChild parses e.execCommand and starts the child process accordingly. Backtick parsing is supported:
./foo `echo $SHELL`
only call this once !
type Renderer ¶
type Renderer struct {
Src string `json:"src"`
Dst string `json:"dst"`
MkDirs bool `toml:"make_directories"`
Mode string `json:"mode"`
UID int `json:"uid"`
GID int `json:"gid"`
ReloadCmd string `toml:"reload_cmd" json:"reload_cmd"`
CheckCmd string `toml:"check_cmd" json:"check_cmd"`
ReapLock *sync.RWMutex
// contains filtered or unexported fields
}
Renderer contains all data needed for the template processing
type Resource ¶
type Resource struct {
// SignalChan is a channel to send os.Signal's to all child processes.
SignalChan chan os.Signal
// Failed is true if we run Monitor() in exec mode and the child process exits unexpectedly.
// If the monitor context is canceled as usual Failed is false.
// Failed is used to restart the Resource on failure.
Failed bool
// Set to true if this resource has backends only using "Onetime=true" flag to
// exit on failure if the resource has some templating error
OnetimeOnly bool
// contains filtered or unexported fields
}
Resource is the representation of a parsed template resource.
func NewResource ¶
func NewResource(backends []Backend, sources []*Renderer, name string, exec Executor, startCmd, reloadCmd string) (*Resource, error)
NewResource creates a Resource.
func NewResourceFromResourceConfig ¶
func NewResourceFromResourceConfig(ctx context.Context, reapLock *sync.RWMutex, r ResourceConfig) (*Resource, error)
NewResourceFromResourceConfig creates a new resource from the given ResourceConfig.
type ResourceConfig ¶
type ResourceConfig struct {
Exec ExecConfig
StartCmd string
ReloadCmd string
// Template is the configuration for all template options.
// You can configure as much template-destination pairs as you like.
Template []*Renderer
// Name gives the Resource a name.
// This name is added to the logs to distinguish between different resources.
Name string
// Connectors is a list of BackendConnectors.
// The Resource will establish a connection to all of these.
Connectors []BackendConnector
}
ResourceConfig is a configuration struct to create a new resource.