gopkg.in/rethinkdb/rethinkdb-go.v6@v6.2.2/query_admin.go (about)

     1  package rethinkdb
     2  
     3  import (
     4  	p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2"
     5  )
     6  
     7  // Config can be used to read and/or update the configurations for individual
     8  // tables or databases.
     9  func (t Term) Config() Term {
    10  	return constructMethodTerm(t, "Config", p.Term_CONFIG, []interface{}{}, map[string]interface{}{})
    11  }
    12  
    13  // Rebalance rebalances the shards of a table. When called on a database, all
    14  // the tables in that database will be rebalanced.
    15  func (t Term) Rebalance() Term {
    16  	return constructMethodTerm(t, "Rebalance", p.Term_REBALANCE, []interface{}{}, map[string]interface{}{})
    17  }
    18  
    19  // ReconfigureOpts contains the optional arguments for the Reconfigure term.
    20  type ReconfigureOpts struct {
    21  	Shards               interface{} `rethinkdb:"shards,omitempty"`
    22  	Replicas             interface{} `rethinkdb:"replicas,omitempty"`
    23  	DryRun               interface{} `rethinkdb:"dry_run,omitempty"`
    24  	EmergencyRepair      interface{} `rethinkdb:"emergency_repair,omitempty"`
    25  	NonVotingReplicaTags interface{} `rethinkdb:"nonvoting_replica_tags,omitempty"`
    26  	PrimaryReplicaTag    interface{} `rethinkdb:"primary_replica_tag,omitempty"`
    27  }
    28  
    29  func (o ReconfigureOpts) toMap() map[string]interface{} {
    30  	return optArgsToMap(o)
    31  }
    32  
    33  // Reconfigure a table's sharding and replication.
    34  func (t Term) Reconfigure(optArgs ...ReconfigureOpts) Term {
    35  	opts := map[string]interface{}{}
    36  	if len(optArgs) >= 1 {
    37  		opts = optArgs[0].toMap()
    38  	}
    39  	return constructMethodTerm(t, "Reconfigure", p.Term_RECONFIGURE, []interface{}{}, opts)
    40  }
    41  
    42  // Status return the status of a table
    43  func (t Term) Status() Term {
    44  	return constructMethodTerm(t, "Status", p.Term_STATUS, []interface{}{}, map[string]interface{}{})
    45  }
    46  
    47  // WaitOpts contains the optional arguments for the Wait term.
    48  type WaitOpts struct {
    49  	WaitFor interface{} `rethinkdb:"wait_for,omitempty"`
    50  	Timeout interface{} `rethinkdb:"timeout,omitempty"`
    51  }
    52  
    53  func (o WaitOpts) toMap() map[string]interface{} {
    54  	return optArgsToMap(o)
    55  }
    56  
    57  // Wait for a table or all the tables in a database to be ready. A table may be
    58  // temporarily unavailable after creation, rebalancing or reconfiguring. The
    59  // wait command blocks until the given table (or database) is fully up to date.
    60  //
    61  // Deprecated: This function is not supported by RethinkDB 2.3 and above.
    62  func Wait(optArgs ...WaitOpts) Term {
    63  	opts := map[string]interface{}{}
    64  	if len(optArgs) >= 1 {
    65  		opts = optArgs[0].toMap()
    66  	}
    67  	return constructRootTerm("Wait", p.Term_WAIT, []interface{}{}, opts)
    68  }
    69  
    70  // Wait for a table or all the tables in a database to be ready. A table may be
    71  // temporarily unavailable after creation, rebalancing or reconfiguring. The
    72  // wait command blocks until the given table (or database) is fully up to date.
    73  func (t Term) Wait(optArgs ...WaitOpts) Term {
    74  	opts := map[string]interface{}{}
    75  	if len(optArgs) >= 1 {
    76  		opts = optArgs[0].toMap()
    77  	}
    78  	return constructMethodTerm(t, "Wait", p.Term_WAIT, []interface{}{}, opts)
    79  }
    80  
    81  // Grant modifies access permissions for a user account, globally or on a
    82  // per-database or per-table basis.
    83  func Grant(args ...interface{}) Term {
    84  	return constructRootTerm("Grant", p.Term_GRANT, args, map[string]interface{}{})
    85  }
    86  
    87  // Grant modifies access permissions for a user account, globally or on a
    88  // per-database or per-table basis.
    89  func (t Term) Grant(args ...interface{}) Term {
    90  	return constructMethodTerm(t, "Grant", p.Term_GRANT, args, map[string]interface{}{})
    91  }