-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
query_admin.go
73 lines (62 loc) · 2.68 KB
/
query_admin.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
63
64
65
66
67
68
69
70
71
72
73
package gorethink
import (
p "github.com/dancannon/gorethink/ql2"
)
// Config can be used to read and/or update the configurations for individual
// tables or databases.
func (t Term) Config() Term {
return constructMethodTerm(t, "Config", p.Term_CONFIG, []interface{}{}, map[string]interface{}{})
}
// Rebalance rebalances the shards of a table. When called on a database, all
// the tables in that database will be rebalanced.
func (t Term) Rebalance() Term {
return constructMethodTerm(t, "Rebalance", p.Term_REBALANCE, []interface{}{}, map[string]interface{}{})
}
// ReconfigureOpts contains the optional arguments for the Reconfigure term.
type ReconfigureOpts struct {
Shards interface{} `gorethink:"shards,omitempty"`
Replicas interface{} `gorethink:"replicas,omitempty"`
PrimaryTag interface{} `gorethink:"primary_replicas_tag,omitempty"`
DryRun interface{} `gorethink:"dry_run,omitempty"`
EmergencyRepair interface{} `gorethink:"emergency_repair,omitempty"`
NonVotingReplicaTags interface{} `gorethink:"nonvoting_replica_tags,omitempty"`
}
func (o *ReconfigureOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// Reconfigure a table's sharding and replication.
func (t Term) Reconfigure(opts ReconfigureOpts) Term {
return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts.toMap())
}
// Status return the status of a table
func (t Term) Status() Term {
return constructMethodTerm(t, "Status", p.Term_STATUS, []interface{}{}, map[string]interface{}{})
}
// WaitOpts contains the optional arguments for the Wait term.
type WaitOpts struct {
WaitFor interface{} `gorethink:"wait_for,omitempty"`
Timeout interface{} `gorethink:"timeout,omitempty"`
}
func (o *WaitOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// Wait for a table or all the tables in a database to be ready. A table may be
// temporarily unavailable after creation, rebalancing or reconfiguring. The
// wait command blocks until the given table (or database) is fully up to date.
func Wait(optArgs ...WaitOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Wait", p.Term_WAIT, []interface{}{}, opts)
}
// Wait for a table or all the tables in a database to be ready. A table may be
// temporarily unavailable after creation, rebalancing or reconfiguring. The
// wait command blocks until the given table (or database) is fully up to date.
func (t Term) Wait(optArgs ...WaitOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Wait", p.Term_WAIT, []interface{}{}, opts)
}