github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/internal/fs/client/resultdetails.templ (about)

     1  // generated code; DO NOT EDIT
     2  
     3  package {{ .Package }}
     4  
     5  import (
     6  	"time"
     7  
     8  	"github.com/choria-io/go-choria/providers/agent/mcorpc"
     9  )
    10  
    11  // ResultDetails is the details about a result
    12  type ResultDetails struct {
    13  	sender  string
    14  	code    int
    15  	message string
    16  	ts      time.Time
    17  }
    18  
    19  // StatusCode is a reply status as defined by MCollective SimpleRPC - integers 0 to 5
    20  //
    21  // See the constants OK, RPCAborted, UnknownRPCAction, MissingRPCData, InvalidRPCData and UnknownRPCError
    22  type StatusCode uint8
    23  
    24  const (
    25  	// OK is the reply status when all worked
    26  	OK = StatusCode(iota)
    27  
    28  	// Aborted is status for when the action could not run, most failures in an action should set this
    29  	Aborted
    30  
    31  	// UnknownAction is the status for unknown actions requested
    32  	UnknownAction
    33  
    34  	// MissingData is the status for missing input data
    35  	MissingData
    36  
    37  	// InvalidData is the status for invalid input data
    38  	InvalidData
    39  
    40  	// UnknownError is the status general failures in agents should set when things go bad
    41  	UnknownError
    42  )
    43  
    44  // Sender is the identity of the remote that produced the message
    45  func (d *ResultDetails) Sender() string {
    46  	return d.sender
    47  }
    48  
    49  // OK determines if the request was successful
    50  func (d *ResultDetails) OK() bool {
    51  	return mcorpc.StatusCode(d.code) == mcorpc.OK
    52  }
    53  
    54  // StatusMessage is the status message produced by the remote
    55  func (d *ResultDetails) StatusMessage() string {
    56  	return d.message
    57  }
    58  
    59  // StatusCode is the status code produced by the remote
    60  func (d *ResultDetails) StatusCode() StatusCode {
    61  	return StatusCode(d.code)
    62  }