Documentation
¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0 Package executor implements the executor module which is able to execute an individual command and forward the standard input, standard error, and go errors by a set of channels
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOutput ¶
func NewOutput() (OutputSend, OutputReceive)
NewOutput creates a default OutputSend group as well as the read-only view.
Types ¶
type Config ¶
type Config struct { User string Directory string IntegrationName string // Manually specified variables Environment map[string]string // Global variables that need to be retrieved before the integration runs Passthrough []string }
Config describes the context to execute a command: user, directory and environment variables.
func (*Config) BuildEnv ¶
BuildEnv returns the environment configuration of an executable, merging the user-defined environment variables from the configuration files with the global passthrough_environment configuration. For backwards-compatibility reasons, the passthrough has higher precedence than the configured Environment
type Executor ¶
Executor handles Executable commands asynchronously.
func FromCmdSlice ¶
FromCmdSlice builds a Executor instance from a string slices, being the first element the command path/name and the next, the command arguments
func (*Executor) DeepClone ¶
DeepClone returns an exact copy of an Executor, without references to the same data structures. It will allow replacing ${config.path} variables by the agent in several executor instances.
func (*Executor) Execute ¶
func (r *Executor) Execute(ctx context.Context, pidChan, exitCodeCh chan<- int) OutputReceive
Execute runs the command in background, sending by a channel the standard output and error, as well as any execution error may happen (task can't start, task is killed...). The executed process can be cancelled via the provided Context. When writable PID channel is provided, generated PID will be written, so process could be signaled by 3rd parties. When the process ends, all the channels are closed.
type OutputReceive ¶
type OutputReceive struct { // Stdout is received line by line. It is closed when the task ends Stdout <-chan []byte // Stderr is received line by line. It is closed when the task ends Stderr <-chan []byte // Errors receives any execution error or error exit status. It is closed when the task ends Errors <-chan error // Done is a channel that is closed when the integration has finished Done <-chan struct{} }
OutputReceive is a receive-only view of OutputSend, made for the sake of safety.
type OutputSend ¶
type OutputSend struct { // Stdout is received line by line. It is closed when the task ends Stdout chan<- []byte // Stderr is received line by line. It is closed when the task ends Stderr chan<- []byte // Errors receives any execution error or error exit status. It is closed when the task ends Errors chan<- error // Done is a channel that is closed when the integration has finished Done chan<- struct{} }
OutputSend holds information about a running task
func (*OutputSend) Close ¶
func (t *OutputSend) Close()
Close closes all the channels of a task output