From 60e342228ba8017e1cacc71a64280143832e7719 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Fri, 26 Jan 2018 17:08:38 +0100 Subject: Added SplitLineTime and SplitTime support in eows - Used SplitTime to split command output by line - Used SplitLineTime to split command output by line or until a timeout has passed. Signed-off-by: Sebastien Douheret --- golib/eows/eows.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'golib/eows/eows.go') diff --git a/golib/eows/eows.go b/golib/eows/eows.go index a5767ed..192be3d 100644 --- a/golib/eows/eows.go +++ b/golib/eows/eows.go @@ -28,6 +28,10 @@ const ( SplitLine SplitType = iota // SplitChar Split character by character SplitChar + // SplitLineTime Split by line or until a timeout has passed + SplitLineTime + // SplitTime Split until a timeout has passed + SplitTime ) // Inspired by : @@ -51,6 +55,7 @@ type ExecOverWS struct { ExitCB EmitExitCB // exit proc callback UserData *map[string]interface{} // user data passed to callbacks OutSplit SplitType // split method to tokenize stdout/stderr + LineTimeSpan int64 // time span (only used with SplitTime or SplitLineTime) // Private fields proc *os.Process @@ -67,8 +72,9 @@ func New(cmd string, args []string, so *socketio.Socket, soID, cmdID string) *Ex SocketIO: so, Sid: soID, CmdID: cmdID, - CmdExecTimeout: -1, // default no timeout - OutSplit: SplitChar, // default split by character + CmdExecTimeout: -1, // default no timeout + OutSplit: SplitLineTime, // default split by line with time + LineTimeSpan: 500 * time.Millisecond.Nanoseconds(), } cmdIDMap[cmdID] = e -- cgit 1.2.3-korg