rethink

package
v0.0.0-...-2e5e463 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2018 License: MIT Imports: 7 Imported by: 4

Documentation

Index

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) Close

func (c *Connection) Close() error

Close the current session

func (*Connection) Connect

func (c *Connection) Connect() error

Connect connects you to Rethink

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

func (*Connection) Update

func (c *Connection) Update(table string, uid string, data map[string]interface{}) (interface{}, error)

Update takes the table the record is in, the UUID of the record, and the data to update it with - then updates the record (°Д°)

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

type RetrievalResult struct {
	Success     bool
	SoftDeleted bool
	Message     string
}

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

func NewMonitor(tables []string, dbs []string) Status

NewMonitor initializes a new Status monitor for the tables and DBs given

func (*Status) APIStatusHandler

func (s *Status) APIStatusHandler(ctx *gin.Context)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL