forked from basho/riak-go-client
/
command_impl.go
48 lines (39 loc) · 969 Bytes
/
command_impl.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
package riak
type commandImpl struct {
error error
success bool
remainingTries byte
lastNode *Node
}
func (cmd *commandImpl) Success() bool {
return cmd.success == true
}
func (cmd *commandImpl) Error() error {
return cmd.error
}
func (cmd *commandImpl) onError(err error) {
cmd.success = false
// NB: only set error to the *last* error (retries)
if !cmd.hasRemainingTries() {
cmd.error = err
}
}
func (cmd *commandImpl) setRemainingTries(tries byte) {
cmd.remainingTries = tries
}
func (cmd *commandImpl) decrementRemainingTries() {
cmd.remainingTries--
logDebug("[commandImpl]", "remainingTries: %d", cmd.remainingTries)
}
func (cmd *commandImpl) hasRemainingTries() bool {
return cmd.remainingTries > 0
}
func (cmd *commandImpl) setLastNode(lastNode *Node) {
if lastNode == nil {
panic("[commandImpl] nil last node")
}
cmd.lastNode = lastNode
}
func (cmd *commandImpl) getLastNode() *Node {
return cmd.lastNode
}