forked from rethinkdb/rethinkdb-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_admin.go
85 lines (73 loc) · 3.08 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
74
75
76
77
78
79
80
81
82
83
84
85
package gorethink
import (
p "gopkg.in/dancannon/gorethink.v2/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"`
DryRun interface{} `gorethink:"dry_run,omitempty"`
EmergencyRepair interface{} `gorethink:"emergency_repair,omitempty"`
NonVotingReplicaTags interface{} `gorethink:"nonvoting_replica_tags,omitempty"`
PrimaryReplicaTag interface{} `gorethink:"primary_replica_tag,omitempty"`
}
func (o ReconfigureOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// Reconfigure a table's sharding and replication.
func (t Term) Reconfigure(optArgs ...ReconfigureOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts)
}
// 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.
//
// Deprecated: This function is not supported by RethinkDB 2.3 and above.
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)
}
// Grant modifies access permissions for a user account, globally or on a
// per-database or per-table basis.
func (t Term) Grant(args ...interface{}) Term {
return constructMethodTerm(t, "Grant", p.Term_GRANT, args, map[string]interface{}{})
}