db

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

README

db

import "github.com/coralproject/shelf/internal/platform/db"

Overview

Package db abstracts different database systems we can use.

Index

Package files

cayley.go db.go mongo.go

Variables

var ErrGraphHandle = errors.New("Graph handle not initialized.")

ErrGraphHandle is returned when a graph handle is not initialized.

var ErrInvalidDBProvided = errors.New("Invalid DB provided")

ErrInvalidDBProvided is returned in the event that an uninitialized db is used to perform actions against.

func RegMasterSession

func RegMasterSession(context interface{}, name string, url string, timeout time.Duration) error

RegMasterSession adds a new master session to the set. If no url is provided, it will default to localhost:27017.

type DB

type DB struct {
    // contains filtered or unexported fields
}

DB is a collection of support for different DB technologies. Currently only MongoDB has been implemented. We want to be able to access the raw database support for the given DB so an interface does not work. Each database is too different.

func NewMGO
func NewMGO(context interface{}, name string) (*DB, error)

NewMGO returns a new DB value for use with MongoDB based on a registered master session.

func (*DB) BatchedQueryMGO
func (db *DB) BatchedQueryMGO(context interface{}, colName string, q bson.M) (*mgo.Iter, error)

BatchedQueryMGO returns an iterator capable of iterating over all the results of a query in batches.

func (*DB) BulkOperationMGO
func (db *DB) BulkOperationMGO(context interface{}, colName string) (*mgo.Bulk, error)

BulkOperationMGO returns a bulk value that allows multiple orthogonal changes to be delivered to the server.

func (*DB) CloseCayley
func (db *DB) CloseCayley(context interface{})

CloseCayley closes a graph handle value.

func (*DB) CloseMGO
func (db *DB) CloseMGO(context interface{})

CloseMGO closes a DB value being used with MongoDB.

func (*DB) CollectionMGO
func (db *DB) CollectionMGO(context interface{}, colName string) (*mgo.Collection, error)

CollectionMGO is used to get a collection value.

func (*DB) CollectionMGOTimeout
func (db *DB) CollectionMGOTimeout(context interface{}, timeout time.Duration, colName string) (*mgo.Collection, error)

CollectionMGOTimeout is used to get a collection value with a timeout.

func (*DB) ExecuteMGO
func (db *DB) ExecuteMGO(context interface{}, colName string, f func(*mgo.Collection) error) error

ExecuteMGO is used to execute MongoDB commands.

func (*DB) ExecuteMGOTimeout
func (db *DB) ExecuteMGOTimeout(context interface{}, timeout time.Duration, colName string, f func(*mgo.Collection) error) error

ExecuteMGOTimeout is used to execute MongoDB commands with a timeout.

func (*DB) GraphHandle
func (db *DB) GraphHandle(context interface{}) (*cayley.Handle, error)

GraphHandle returns the Cayley graph handle for graph interactions.

func (*DB) NewCayley
func (db *DB) NewCayley(context interface{}, name string) error

NewCayley adds support to a DB value for cayley based on a registered master cayley handle.


Generated by godoc2md

Documentation

Overview

Package db abstracts different database systems we can use.

Index

Constants

This section is empty.

Variables

View Source
var ErrGraphHandle = errors.New("Graph handle not initialized.")

ErrGraphHandle is returned when a graph handle is not initialized.

View Source
var ErrInvalidDBProvided = errors.New("Invalid DB provided")

ErrInvalidDBProvided is returned in the event that an uninitialized db is used to perform actions against.

Functions

func RegMasterSession

func RegMasterSession(context interface{}, name string, url string, timeout time.Duration) error

RegMasterSession adds a new master session to the set. If no url is provided, it will default to localhost:27017.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a collection of support for different DB technologies. Currently only MongoDB has been implemented. We want to be able to access the raw database support for the given DB so an interface does not work. Each database is too different.

func NewMGO

func NewMGO(context interface{}, name string) (*DB, error)

NewMGO returns a new DB value for use with MongoDB based on a registered master session.

func (*DB) BatchedQueryMGO

func (db *DB) BatchedQueryMGO(context interface{}, colName string, q bson.M) (*mgo.Iter, error)

BatchedQueryMGO returns an iterator capable of iterating over all the results of a query in batches.

func (*DB) BulkOperationMGO

func (db *DB) BulkOperationMGO(context interface{}, colName string) (*mgo.Bulk, error)

BulkOperationMGO returns a bulk value that allows multiple orthogonal changes to be delivered to the server.

func (*DB) CloseCayley

func (db *DB) CloseCayley(context interface{})

CloseCayley closes a graph handle value.

func (*DB) CloseMGO

func (db *DB) CloseMGO(context interface{})

CloseMGO closes a DB value being used with MongoDB.

func (*DB) CollectionMGO

func (db *DB) CollectionMGO(context interface{}, colName string) (*mgo.Collection, error)

CollectionMGO is used to get a collection value.

func (*DB) CollectionMGOTimeout

func (db *DB) CollectionMGOTimeout(context interface{}, timeout time.Duration, colName string) (*mgo.Collection, error)

CollectionMGOTimeout is used to get a collection value with a timeout.

func (*DB) ExecuteMGO

func (db *DB) ExecuteMGO(context interface{}, colName string, f func(*mgo.Collection) error) error

ExecuteMGO is used to execute MongoDB commands.

func (*DB) ExecuteMGOTimeout

func (db *DB) ExecuteMGOTimeout(context interface{}, timeout time.Duration, colName string, f func(*mgo.Collection) error) error

ExecuteMGOTimeout is used to execute MongoDB commands with a timeout.

func (*DB) GraphHandle

func (db *DB) GraphHandle(context interface{}) (*cayley.Handle, error)

GraphHandle returns the Cayley graph handle for graph interactions.

func (*DB) NewCayley added in v0.4.3

func (db *DB) NewCayley(context interface{}, name string) error

NewCayley adds support to a DB value for cayley based on a registered master cayley handle.

Directories

Path Synopsis
Package cayley provides support for the cayley Graph DB with a Mongo backend.
Package cayley provides support for the cayley Graph DB with a Mongo backend.
Package mongo provides support for using MongoDB.
Package mongo provides support for using MongoDB.

Jump to

Keyboard shortcuts

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