forked from aliyun/aliyun-log-go-sdk
/
result.go
62 lines (52 loc) · 1.3 KB
/
result.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
package producer
type Attempt struct {
Success bool
RequestId string
ErrorCode string
ErrorMessage string
TimeStampMs int64
}
func createAttempt(success bool, requestId, errorCode, errorMessage string, timeStampMs int64) *Attempt {
return &Attempt{
Success: success,
RequestId: requestId,
ErrorCode: errorCode,
ErrorMessage: errorMessage,
TimeStampMs: timeStampMs,
}
}
type Result struct {
attemptList []*Attempt
successful bool
}
func (result *Result) IsSuccessful() bool {
return result.successful
}
func (result *Result) GetReservedAttempts() []*Attempt {
return result.attemptList
}
func (result *Result) GetErrorCode() string {
if len(result.attemptList) == 0 {
return ""
}
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].ErrorCode
}
func (result *Result) GetErrorMessage() string {
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].ErrorMessage
}
func (result *Result) GetRequestId() string {
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].RequestId
}
func (result *Result) GetTimeStampMs() int64 {
cursor := len(result.attemptList) - 1
return result.attemptList[cursor].TimeStampMs
}
func initResult() *Result {
return &Result{
attemptList: []*Attempt{},
successful: false,
}
}