Documentation ¶
Index ¶
Constants ¶
const (
JitsuScriptResultCommand = "_JITSU_RESULT"
)
Variables ¶
var ErrOutOfMemory = errors.New("out of memory")
Functions ¶
This section is empty.
Types ¶
type CommandResponse ¶
type CommandResponse struct { Command string `json:"command"` Payload interface{} `json:"payload"` }
type DataListener ¶
type DataListener interface { // Data is called for each line of output. Data(data []byte) }
DataListener is used to listen for multiline execution output.
type Governor ¶
type Governor struct {
// contains filtered or unexported fields
}
Governor is responsible for keeping the Process alive. It will restart the process if it dies.
func (*Governor) Exchange ¶
func (g *Governor) Exchange(ctx context.Context, data []byte, listener DataListener) ([]byte, error)
Exchange sends request data and returns response data.
func (*Governor) ExchangeDirect ¶
type Interface ¶
type Interface interface { // Send sends a message to the process. Send(ctx context.Context, data []byte) error // Receive receives a message from the process. // It is advisable to support context.Context.Done() in method implementations // so as not to infinitely block. Receive(ctx context.Context, listener DataListener) ([]byte, error) }
Interface describes generic IPC interface.
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex provides an interruptible mutex implementation.
type Process ¶
type Process interface { Interface // String should return a human-readable process description. String() string // Spawn spawns a new process copy and returns it. Spawn() (Process, error) // Kill kills the current running process. Kill() // Wait waits for the current process to exit. Returns stderr output if present Wait() (string, error) }
Process describes a process with no acquired state (except for the initial state acquired on start) which can be restarted (respawned) with no data or other loss. Process instance should not be started manually – instead, it should contain all that is necessary to start the process and be supplied to Govern function.
type StdIO ¶
type StdIO struct { Dir string Path string Args []string Env []string CommandProcessor func(commandName string, payload []byte) (*CommandResponse, error) // contains filtered or unexported fields }
StdIO allows to start to process and communicate to it via standard input/output. Note that it currently uses '\n' for delimiting sent messages.