-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcommand.go
33 lines (28 loc) · 1.06 KB
/
command.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
package goriak
// Command is the main query builder object
type Command struct {
// Key information
bucket string
bucketType string
// Middleware
runMiddleware []RunMiddleware
}
// Result contains your query result data from Run()
type Result struct {
NotFound bool // Wether or not the item was not found when using Get, GetJSON, or GetRaw.
Key string // Returns your automatically generated key when using Set, SetJSON, or SetRaw.
Context []byte // Returns the Riak Context used in map operations. Is set when using Get.
}
// Bucket specifies the bucket and bucket type that your following command will be performed on.
func Bucket(bucket, bucketType string) *Command {
return &Command{
bucket: bucket,
bucketType: bucketType,
}
}
// RegisterRunMiddleware adds a middleware function that will wrap the execution of the command.
// Is currently supported by Get, GetRaw, GetJSON, Set, SetRaw, and SetJSON
func (c *Command) RegisterRunMiddleware(middleware RunMiddleware) *Command {
c.runMiddleware = append(c.runMiddleware, middleware)
return c
}