fastexec

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2016 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Fastexec

GoReportCard Widget Travis Widget Coverage Status Widget


About

Fastexec is a tool to parallelly run shell command on data subset.

The idea is simple, fastexec takes data from standard input, divide it into small chunks, pass it to workers running command line in parallel. And then it will return the combined result from all workers.

Examples

Run 1000 workers to curl URLs from the url_list.txt and output response code, time cost for name resolution, connection and for entire request.

cat url_list.txt | fastexec -workers 10000 xargs curl -sL \
-w "%{http_code} %{time_namelookup} %{time_connect} %{time_total} %{url_effective}\\n" -o /dev/null

Parallelly run fping with 400 workers, and each takes 20 IPs from the ip_list.txt. Fping will be triggered with -t 1000 (1000 millisec timeout) and all workers share the 1000 IP/s (1000 line of data / sec) rate limit.

cat ip_list.txt | fastexec -chunks 20 -workers 400 -ratelimit 1000 fping -t 1000
Usage
  -alsologtostderr
        log to standard error as well as files
  -chunks int
        size of data chunk for one job (default 1)
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace (default :0)
  -log_dir string
        If non-empty, write log files in this directory
  -logtostderr
        log to standard error instead of files
  -ratelimit int
        data processing ratelimit / sec (default -1)
  -stderrthreshold value
        logs at or above this threshold go to stderr
  -v value
        log level for V logs
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging
  -workers int
        num of workers (default 1)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config struct {
	// contains filtered or unexported fields
}

Functions

func InitFlags

func InitFlags()

func InitJobPool added in v0.0.2

func InitJobPool(r io.Reader)

init job pool by reading from reader input and break it into chunks

func StartWorkers

func StartWorkers()

func StateMonitor

func StateMonitor(in <-chan Job)

func WaitToFinish

func WaitToFinish()

func Worker

func Worker(in <-chan Job, out chan<- Job)

Types

type ExecJob added in v0.0.2

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

Job contains boths command and data to apply command on

func (*ExecJob) Execute added in v0.0.2

func (j *ExecJob) Execute() error

Execute a Job with associated data

func (ExecJob) GetData added in v0.0.2

func (j ExecJob) GetData() []byte

Get input data from a Job

func (ExecJob) GetErr added in v0.0.3

func (j ExecJob) GetErr() []byte

Get err result from a Job

func (ExecJob) GetResult added in v0.0.2

func (j ExecJob) GetResult() []byte

Get output result from a Job

type Job

type Job interface {
	Execute() error
	GetData() []byte
	GetResult() []byte
	GetErr() []byte
}

Directories

Path Synopsis
cmd
fastexec command

Jump to

Keyboard shortcuts

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