shpool

package
v0.0.0-...-19f838f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package shpool implements pools for running heterogeneous SHELL processes

Index

Constants

This section is empty.

Variables

View Source
var Shell = "/bin/bash"

Functions

This section is empty.

Types

type Options

type Options struct {
	// Stop the entire pool on any error
	StopOnError bool
	// Log outputs will have this prefix
	LogPrefix string
	// don't show the running-type of each process.
	Quiet bool
}

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool orchestrates the work to be done.

func New

func New(cpus int, logger *log.Logger, opts *Options) *Pool

New creates a new pool with either the specified logger, or a logger with the given prefix.

func (*Pool) Add

func (pool *Pool) Add(p Process)

Add a process to the pool.

func (*Pool) Error

func (pool *Pool) Error() error

Error returns any error in the pool

func (*Pool) KillAll

func (pool *Pool) KillAll()

KillAll processes in the pool.

func (*Pool) Wait

func (pool *Pool) Wait() error

Wait until all processes are finished.

type Process

type Process struct {
	// number of cpus used by this command.
	// This will be available as the environment variable 'CPUs' in the running process.
	CPUs int
	// the command to run in the shell.
	Command string
	// Prefix is prepended to the stderr and stdout of this command.
	// This will be available as the env var 'Prefix' in the running process.
	Prefix string
}

Process is filled by the user by specifying the command and the number of CPUs that command will utilize.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL