-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathraw.go
46 lines (36 loc) · 993 Bytes
/
raw.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
package goriak
import (
riak "github.com/basho/riak-go-client"
)
// SetRaw allows you to set a []byte directly to Riak.
// SetRaw gives you full control of the data stored, compared to SetJSON and Set.
func (c *Command) SetRaw(value []byte) *SetRawCommand {
object := &riak.Object{
Value: value,
}
builder := riak.NewStoreValueCommandBuilder().
WithBucket(c.bucket).
WithBucketType(c.bucketType)
return &SetRawCommand{
c: c,
storeValueObject: object,
storeValueCommandBuilder: builder,
}
}
// GetRaw retreives key as a []byte.
// The output will be written to output by Run().
func (c *Command) GetRaw(key string, output *[]byte) *GetRawCommand {
cmd := &GetRawCommand{
c: c,
bucket: c.bucket,
bucketType: c.bucketType,
key: key,
outputBytes: output,
isRawOutput: true,
}
cmd.builder = riak.NewFetchValueCommandBuilder().
WithBucket(c.bucket).
WithBucketType(c.bucketType).
WithKey(key)
return cmd
}