-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.go
57 lines (50 loc) · 1.05 KB
/
delete.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
package rkive
import (
"github.com/philhofer/rkive/rpbc"
)
// DelOpts are options available on delete
// operations. All values are optional.
type DelOpts struct {
R *uint32 // required reads
W *uint32 // required writes
PR *uint32 // required primary node reads
PW *uint32 // required primary node writes
RW *uint32 // required replica deletions
DW *uint32 // required durable (to disk) writes
}
func parseDelOpts(opts *DelOpts, req *rpbc.RpbDelReq) {
if opts == nil || req == nil {
return
}
if opts.W != nil {
req.W = opts.W
}
if opts.DW != nil {
req.Dw = opts.DW
}
if opts.PW != nil {
req.Pw = opts.PW
}
if opts.R != nil {
req.R = opts.R
}
if opts.PR != nil {
req.Pr = opts.R
}
if opts.RW != nil {
req.Rw = opts.RW
}
}
func (c *Client) Delete(o Object, opts *DelOpts) error {
if o.Info().bucket == nil || o.Info().key == nil {
return ErrNoPath
}
req := &rpbc.RpbDelReq{
Bucket: o.Info().bucket,
Key: o.Info().key,
Vclock: o.Info().vclock,
}
parseDelOpts(opts, req)
_, err := c.req(req, 13, nil)
return err
}