mongo

package
v0.0.0-...-53e0952 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_DB_HOST        = "127.0.0.1"
	DEFAULT_DB_PORT        = 27017
	DEFAULT_DB_NAME        = "se_db"
	MEMORY_COLLECTION_NAME = "memory"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Content string `bson:"content"`
	Time    int64  `bson:"time"`
	Type    string `bson:"type"` //string, rpc, http, exec
}

type Memory

type Memory struct {
	Key   string  `bson:"key"`
	Value []Event `bson:"value"`
	Lock  bool    `bson:lock`
}

type Mongo

type Mongo struct {
	Opts    *MongoOptions
	Session *mgo.Session

	ReConnecting bool
	// contains filtered or unexported fields
}

func NewMongo

func NewMongo(opts *MongoOptions) *Mongo

func (*Mongo) Close

func (m *Mongo) Close()

Close

func (*Mongo) Error

func (m *Mongo) Error(err error) error

统一错误处理

func (*Mongo) MemorySelectEventsFromKey

func (m *Mongo) MemorySelectEventsFromKey(Key string) ([]Event, error)

func (*Mongo) MemorySelectOneEventFromKeyRandom

func (m *Mongo) MemorySelectOneEventFromKeyRandom(Key string) (Event, error)

func (*Mongo) ReConnect

func (m *Mongo) ReConnect()

ReConnect

type MongoOptions

type MongoOptions struct {
	Host     string
	Port     uint16
	User     string
	Password string
	DbName   string
	Uri      string
}

Jump to

Keyboard shortcuts

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