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