jproc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jproc handle processes that communicate using json on stdin/stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StdErrCallback

func StdErrCallback(cmd *exec.Cmd, cb func(string)) (io.Closer, error)

StdErrCallback provide an "easy" way to read line from a subprocess stdrror stream.

It should be called on *exec.Cmd before calling Run/Start If it doesn't return an error and for some reason Wait is not called for the process, the Close of the closer should be called.

Types

type Process added in v0.0.3

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

Process represents a process that get requests as json objects streamed to stdin (separated by a new line), and for each request, in order it send a reply to stdout

func Start

func Start(cmd *exec.Cmd) (*Process, error)

Start an new process based on the command line

func StartWithStderr

func StartWithStderr(cmd *exec.Cmd, stderr func(string)) (*Process, error)

StartWithStderr an new process based on the command line and register a callback to be called for each line of stderr

func (*Process) Close added in v0.0.3

func (j *Process) Close() error

Close the process (killing it if it not already dead and stopping waiting goroutines)

func (*Process) Done added in v0.0.3

func (j *Process) Done() <-chan struct{}

Done return a channel is get closed when the process dies Note: If the process never started it return nil

func (*Process) Error added in v0.0.3

func (j *Process) Error() error

Error return the final error code of the process (or nil if doesn't have one)

func (*Process) IsRunning added in v0.0.3

func (j *Process) IsRunning() bool

IsRunning return true if the process can get data

func (*Process) Send added in v0.0.3

func (j *Process) Send(request, reply interface{}) error

Send a request and decode back the reply to reply

Jump to

Keyboard shortcuts

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