github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/client/driver/structs/structs.go (about)

     1  package structs
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  const (
     9  	// The default user that the executor uses to run tasks
    10  	DefaultUnpriviledgedUser = "nobody"
    11  
    12  	// CheckBufSize is the size of the check output result
    13  	CheckBufSize = 4 * 1024
    14  )
    15  
    16  // WaitResult stores the result of a Wait operation.
    17  type WaitResult struct {
    18  	ExitCode int
    19  	Signal   int
    20  	Err      error
    21  }
    22  
    23  func NewWaitResult(code, signal int, err error) *WaitResult {
    24  	return &WaitResult{
    25  		ExitCode: code,
    26  		Signal:   signal,
    27  		Err:      err,
    28  	}
    29  }
    30  
    31  func (r *WaitResult) Successful() bool {
    32  	return r.ExitCode == 0 && r.Signal == 0 && r.Err == nil
    33  }
    34  
    35  func (r *WaitResult) String() string {
    36  	return fmt.Sprintf("Wait returned exit code %v, signal %v, and error %v",
    37  		r.ExitCode, r.Signal, r.Err)
    38  }
    39  
    40  // CheckResult encapsulates the result of a check
    41  type CheckResult struct {
    42  
    43  	// ExitCode is the exit code of the check
    44  	ExitCode int
    45  
    46  	// Output is the output of the check script
    47  	Output string
    48  
    49  	// Timestamp is the time at which the check was executed
    50  	Timestamp time.Time
    51  
    52  	// Duration is the time it took the check to run
    53  	Duration time.Duration
    54  
    55  	// Err is the error that a check returned
    56  	Err error
    57  }
    58  
    59  // ExecutorConfig is the config that Nomad passes to the executor
    60  type ExecutorConfig struct {
    61  
    62  	// LogFile is the file to which Executor logs
    63  	LogFile string
    64  
    65  	// LogLevel is the level of the logs to putout
    66  	LogLevel string
    67  }