Documentation ¶
Index ¶
- func AllowedEnvironment(envs []string) []string
- func ExitStatus(err error) (int, bool)
- func InitContextStats(ctx context.Context) context.Context
- type CgroupsManager
- type Command
- type Option
- func WithCgroup(cgroupsManager CgroupsManager, repo repository.GitRepo) Option
- func WithCommandGitVersion(gitCmdVersion string) Option
- func WithCommandName(commandName, subcommandName string) Option
- func WithEnvironment(environment []string) Option
- func WithFinalizer(finalizer func(*Command)) Option
- func WithSetupStdin() Option
- func WithStderr(stderr io.Writer) Option
- func WithStdin(stdin io.Reader) Option
- func WithStdout(stdout io.Writer) Option
- type SpawnConfig
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowedEnvironment ¶
AllowedEnvironment filters the given slice of environment variables and returns all variables which are allowed per the variables defined above. This is useful for constructing a base environment in which a command can be run.
func ExitStatus ¶
ExitStatus will return the exit-code from an error returned by Wait().
Types ¶
type CgroupsManager ¶ added in v15.2.0
type CgroupsManager interface {
AddCommand(*Command, repository.GitRepo) (string, error)
}
CgroupsManager is a subset of the `cgroups.Manager` interface. We need to replicate it here to avoid a cyclic dependency between both packages.
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command encapsulates a running exec.Cmd. The embedded exec.Cmd is terminated and reaped automatically when the context.Context that created it is canceled.
func New ¶
New creates a Command from an exec.Cmd. On success, the Command contains a running subprocess. When ctx is canceled the embedded process will be terminated and reaped automatically.
type Option ¶ added in v15.2.0
type Option func(cfg *config)
Option is an option that can be passed to `New()` for controlling how the command is being created.
func WithCgroup ¶ added in v15.2.0
func WithCgroup(cgroupsManager CgroupsManager, repo repository.GitRepo) Option
WithCgroup adds the spawned command to a Cgroup. The bucket used will be derived from the command's arguments and/or from the repository.
func WithCommandGitVersion ¶ added in v15.2.0
WithCommandGitVersion overrides the "git_version" label used in metrics.
func WithCommandName ¶ added in v15.2.0
WithCommandName overrides the "cmd" and "subcmd" label used in metrics.
func WithEnvironment ¶ added in v15.2.0
WithEnvironment sets up environment variables that shall be set for the command.
func WithFinalizer ¶ added in v15.2.0
WithFinalizer sets up the finalizer to be run when the command is being wrapped up. It will be called after `Wait()` has returned.
func WithSetupStdin ¶ added in v15.2.0
func WithSetupStdin() Option
WithSetupStdin instructs New() to configure the stdin pipe of the command it is creating. This allows you call Write() on the command as if it is an ordinary io.Writer, sending data directly to the stdin of the process.
func WithStderr ¶ added in v15.2.0
WithStderr sets up the command to write standard error to the given writer.
func WithStdout ¶ added in v15.2.0
WithStdout sets up the command to write standard output to the given writer.
type SpawnConfig ¶
type SpawnConfig struct { // This default value (10 seconds) is very high. Spawning should take // milliseconds or less. If we hit 10 seconds, something is wrong, and // failing the request will create breathing room. Can be modified at // runtime with the GITALY_COMMAND_SPAWN_TIMEOUT environment variable. Timeout time.Duration `split_words:"true" default:"10s"` // MaxSpawnParallel limits the number of goroutines that can spawn a // process at the same time. These parallel spawns will contend for a // single lock (syscall.ForkLock) in exec.Cmd.Start(). Can be modified at // runtime with the GITALY_COMMAND_SPAWN_MAX_PARALLEL variable. // // Note that this does not limit the total number of child processes that // can be attached to Gitaly at the same time. It only limits the rate at // which we can create new child processes. MaxParallel int `split_words:"true" default:"10"` }
SpawnConfig holds configuration for command spawning timeouts and parallelism.
type Stats ¶
nolint: revive,stylecheck // This is unintentionally missing documentation.
func StatsFromContext ¶
nolint: revive,stylecheck // This is unintentionally missing documentation.