storage

package
v0.0.0-...-c1f947c Latest Latest
Warning

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

Go to latest
Published: May 13, 2015 License: GPL-3.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestDB *testDB // singleton
)

Functions

func NewTestDBMongo

func NewTestDBMongo(m *MongoDB) *testDB

Using a MongoDB backend, export a testing database (done so we don't have to export the testDB struct).

Types

type MockStorage

type MockStorage map[string]map[string]string

func NewMockStorage

func NewMockStorage() *MockStorage

func (*MockStorage) CloseConnection

func (m *MockStorage) CloseConnection()

func (*MockStorage) InsertRecord

func (m *MockStorage) InsertRecord(key string, url string, collection string) (err error)

func (*MockStorage) OpenConnection

func (m *MockStorage) OpenConnection() (err error)

func (*MockStorage) String

func (m *MockStorage) String() string

type MongoDB

type MongoDB struct {
	Host, Port         string
	Database           string
	Username, Password string
	// contains filtered or unexported fields
}

func (*MongoDB) CloneSession

func (m *MongoDB) CloneSession() (session *mgo.Session)

func (*MongoDB) CloseConnection

func (m *MongoDB) CloseConnection()

Close a MongoDB connection

func (*MongoDB) InsertRecord

func (m *MongoDB) InsertRecord(key string, url string, collection string) (err error)

Insert a new index record into the database.

func (*MongoDB) OpenConnection

func (m *MongoDB) OpenConnection() (err error)

Open a MongoDB connection.

type MongoDBError

type MongoDBError string

func (MongoDBError) Error

func (e MongoDBError) Error() string

type ReverseIndex

type ReverseIndex struct {
	ID  bson.ObjectId `bson:"_id,omitempty"`
	Key string        `bson:"key"`
	// URLs are a list for now, eventually each will be a (weighted) element
	// so a proper index ranking can be made
	URLs []string `bson:"urls"`
}

A reverse index representation of a bson MongoDB object.

type Storage

type Storage interface {
	OpenConnection() error
	CloseConnection()
	InsertRecord(key string, url string, collection string) error
}

Jump to

Keyboard shortcuts

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