Documentation ¶
Index ¶
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) Connect() error
- func (c *Connection) Create(table string, data map[string]interface{}) (interface{}, error)
- func (c *Connection) Delete(table string, uid string) (interface{}, error)
- func (c *Connection) Disable(table string, uid string) (interface{}, error)
- func (c *Connection) GetAll(table string) ([]interface{}, error)
- func (c *Connection) GetByFilter(table string, filter map[string]interface{}, limit int) ([]interface{}, error)
- func (c *Connection) GetByUUID(uuid string, table string) (interface{}, error)
- func (c *Connection) GetMultiple(table string, limit int) ([]interface{}, error)
- func (c *Connection) GetRandom(table string, filter map[string]interface{}) (interface{}, error)
- func (c *Connection) GetSingle(filter map[string]interface{}, table string) (interface{}, error)
- func (c *Connection) Status() ([]Issue, error)
- func (c *Connection) Update(table string, uid string, data map[string]interface{}) (interface{}, error)
- type ConnectionOpts
- type Database
- type Issue
- type RetrievalResult
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { DB string // The Rethink DB to use Opts ConnectionOpts // Connection options for connecting to the Rethink server Session *r.Session // The connected session }
Connection defines a connection to a RethinkDB instance
func (*Connection) Create ¶
func (c *Connection) Create(table string, data map[string]interface{}) (interface{}, error)
Create takes the table the record is in and the data to update it with, and creates a new record @(・0・)@
func (*Connection) Delete ¶
func (c *Connection) Delete(table string, uid string) (interface{}, error)
Delete hard deletes a record
func (*Connection) Disable ¶
func (c *Connection) Disable(table string, uid string) (interface{}, error)
Disable ... well, it deletes a record. Softly.
func (*Connection) GetAll ¶
func (c *Connection) GetAll(table string) ([]interface{}, error)
GetAll returns all the record in a table, a wrapper around GetMultiple
func (*Connection) GetByFilter ¶
func (c *Connection) GetByFilter(table string, filter map[string]interface{}, limit int) ([]interface{}, error)
GetByFilter is like GetMultiple, except it has the ability to filter the results first
func (*Connection) GetByUUID ¶
func (c *Connection) GetByUUID(uuid string, table string) (interface{}, error)
GetByUUID returns a single object from the current table via the uuid
func (*Connection) GetMultiple ¶
func (c *Connection) GetMultiple(table string, limit int) ([]interface{}, error)
GetMultiple returns multiple records from a table
func (*Connection) GetRandom ¶
func (c *Connection) GetRandom(table string, filter map[string]interface{}) (interface{}, error)
GetRandom retrieves a single random record from the table given the filter
func (*Connection) GetSingle ¶
func (c *Connection) GetSingle(filter map[string]interface{}, table string) (interface{}, error)
GetSingle returns a single object from the current table via a filter key
func (*Connection) Status ¶
func (c *Connection) Status() ([]Issue, error)
Status returns status of the table specified
type ConnectionOpts ¶
type ConnectionOpts struct { Host string `json:"host"` User string `json:"user"` Password string `json:"password"` }
ConnectionOpts is what we need to connect to a RethinkDB server
type Database ¶
type Database interface { Connect() error Close() error GetSingle(table string) (interface{}, error) GetMultiple(table string, limit int) ([]interface{}, error) GetAll(table string) ([]interface{}, error) GetByUUID(table string, uid string) (interface{}, error) GetByFilter(table string, filter map[string]interface{}, limit int) ([]interface{}, error) GetRandom(table string, filter map[string]interface{}) (interface{}, error) Update(table string, uid string, data map[string]interface{}) (interface{}, error) Create(table string, data map[string]interface{}) (interface{}, error) Delete(table string, uid string) (interface{}, error) // Hard deletion Disable(table string, uid string) (interface{}, error) // Soft deletion Exists(table string, filter map[string]interface{}) (interface{}, error) Status(table string) (interface{}, error) }
Database is a set of methods that must be implemented for an object to implement the Database interface Makes it easier if we change databases in the future
type Issue ¶
type Issue struct { ID string Type string Critical bool Info map[string]interface{} Description string }
Issue is the schema for any responses from RethinkDB will be in for any active issues
type RetrievalResult ¶
RetrievalResult is a specific type of error object used for tracking the result of a database retrieval operation
func (RetrievalResult) Error ¶
func (rr RetrievalResult) Error() string
type Status ¶
type Status struct { Tables map[string]struct{} // All tables we're monitoring DBs map[string]struct{} // All databases we're monitoring Issues []Issue // Any active issues LastUpdated time.Time // The last time any value was updated }
Status keeps track of the status
func NewMonitor ¶
NewMonitor initializes a new Status monitor for the tables and DBs given
func (*Status) APIStatusHandler ¶
APIStatusHandler returns the current status of the API, as of
func (*Status) Monitor ¶
func (s *Status) Monitor(c *Connection)
Monitor monitors the connection status for the DB and can reconnect