open-nomad/client/driver/structs/structs.go

58 lines
1.1 KiB
Go
Raw Normal View History

package structs
2016-02-19 22:01:07 +00:00
import (
"fmt"
"time"
2016-02-19 22:01:07 +00:00
)
const (
2016-03-18 22:04:15 +00:00
// The default user that the executor uses to run tasks
DefaultUnpriviledgedUser = "nobody"
// CheckBufSize is the size of the check output result
CheckBufSize = 4 * 1024
)
// WaitResult stores the result of a Wait operation.
type WaitResult struct {
ExitCode int
Signal int
Err error
}
func NewWaitResult(code, signal int, err error) *WaitResult {
return &WaitResult{
ExitCode: code,
Signal: signal,
Err: err,
}
}
func (r *WaitResult) Successful() bool {
return r.ExitCode == 0 && r.Signal == 0 && r.Err == nil
}
func (r *WaitResult) String() string {
return fmt.Sprintf("Wait returned exit code %v, signal %v, and error %v",
r.ExitCode, r.Signal, r.Err)
}
2016-02-19 22:01:07 +00:00
// CheckResult encapsulates the result of a check
type CheckResult struct {
2016-05-05 17:45:02 +00:00
// ExitCode is the exit code of the check
ExitCode int
// Output is the output of the check script
Output string
// Timestamp is the time at which the check was executed
Timestamp time.Time
2016-05-05 17:45:02 +00:00
// Duration is the time it took the check to run
Duration time.Duration
// Err is the error that a check returned
Err error
}