aboutsummaryrefslogtreecommitdiffstats
path: root/golib/eows/eows.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-26 17:08:38 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-01-26 17:08:45 +0100
commit60e342228ba8017e1cacc71a64280143832e7719 (patch)
treef3f9fa8f742bcdbabdc786b7e4f6d4a59f24dab1 /golib/eows/eows.go
parentfafb1d20fe1f67935292823ad6651fff28deefc4 (diff)
Added SplitLineTime and SplitTime support in eowsv0.1.9eel_5.0.1eel/5.0.15.0.1
- 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 <sebastien.douheret@iot.bzh>
Diffstat (limited to 'golib/eows/eows.go')
-rw-r--r--golib/eows/eows.go10
1 files changed, 8 insertions, 2 deletions
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