mds

package module
v0.0.0-...-facc28c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2015 License: MIT Imports: 6 Imported by: 1

README

mds During the development :)

Build Status codecov.io

msd is a library for managing multiple databases.

Features

  • Another name on the can be managed as multiple databases.
  • Support database
    • MongoDB
    • Redis
    • RethinkDB

Requirements

Test

Getting started

$ go get github.com/dogenzaka/mds

Example

Please read the test code.

Developer

Started

$ make init-test

Test

$ make test
or
$ make cover

License

MIT License

Documentation

Index

Constants

View Source
const (
	// mds version
	VERSION = "0.0.1"

	// type: MongoDB
	MONGODB = "MongoDB"
)

Variables

View Source
var DEBUG = false

Debug flag

Functions

func AddDataStore

func AddDataStore(dn string, value interface{}) interface{}

Add a datastore

func Debug

func Debug(f string, msgs ...string)

Debug output

func GetDataStore

func GetDataStore(dn string) (interface{}, error)

Get a datastore

func Setup

func Setup(dss []map[string]interface{}, autoconnect bool) error

mds setup (Once) autoconnect: connect automatically

func String

func String() string

mds to string

Types

type Collection

type Collection struct {
	*mgo.Collection
	Session *mgo.Session `json:"-" bson:"-"`
}

Mongodb#Collection

func (*Collection) Close

func (c *Collection) Close()

Return back session into pool

type Mds

type Mds struct {
	DataStores map[string]interface{}
	Version    string
	Setuped    bool
}

Global Mds

func Get

func Get() *Mds

Mds info

type MongoDB

type MongoDB struct {
	Use       bool
	Dn        string
	Type      string
	DialInfo  *mgo.DialInfo
	Session   *mgo.Session
	Connected bool
}

MongoDB

func GetDataStoreMongoDB

func GetDataStoreMongoDB(dn string) (*MongoDB, error)

Get the Mongodb datastore

func (*MongoDB) Connect

func (m *MongoDB) Connect() error

Connecting to Mongodb

func (*MongoDB) CopySession

func (m *MongoDB) CopySession() (*mgo.Session, error)

Get a new session

func (*MongoDB) GetCollection

func (m *MongoDB) GetCollection(colname string, makeSession bool) (*Collection, error)

Get Collection

func (*MongoDB) GetCollectionWithoutErr

func (m *MongoDB) GetCollectionWithoutErr(colname string, makeSession bool, exit bool) *Collection

Get Collection without any errors if exit == true, shutdown this application immediatry.

func (*MongoDB) GetDataBase

func (m *MongoDB) GetDataBase(dbname string, makeSession bool) (*mgo.Database, error)

Get Database

func (*MongoDB) GetSession

func (m *MongoDB) GetSession(makeSession bool) (*mgo.Session, error)

Get a session (Singleton)

func (*MongoDB) String

func (m *MongoDB) String() string

MongoDB to string

type MongoDBOption

type MongoDBOption struct {
	Session bool
	DbName  string
	ColName string
}

get options

Jump to

Keyboard shortcuts

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