gonzo

package
v0.0.0-...-3d3a7e0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2016 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Overview

This is just a prototype. Please do not use it.

This is just a prototype. Please do not use it.

Index

Constants

View Source
const (
	ConnectionPrefix = "C"
	DocumentPrefix   = "D"
)
View Source
const (
	QueryFlagTailableCursor  = 1 << 1
	QueryFlagSlaveOk         = 1 << 2
	QueryFlagOplogReplay     = 1 << 3
	QueryFlagNoCursorTimeout = 1 << 4
	QueryFlagAwaitData       = 1 << 5
	QueryFlagExhaust         = 1 << 6
	QueryFlagPartial         = 1 << 7
)
View Source
const (
	UpdateFlagUpsert      = 1 << 0
	UpdateFlagMultiUpdate = 1 << 1
)
View Source
const (
	DeleteFlagSingleRemove = 1 << 0
)
View Source
const (
	InsertFlagContinueOnError = 1 << 0
)

Variables

View Source
var (
	OpReply       = OpCode(1)
	OpMsg         = OpCode(1000)
	OpUpdate      = OpCode(2001)
	OpInsert      = OpCode(2002)
	OpQuery       = OpCode(2004)
	OpGetMore     = OpCode(2005)
	OpDelete      = OpCode(2006)
	OpKillCursors = OpCode(2007)
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	HandleQuery(c net.Conn, query *OpQueryMsg)
	HandleInsert(c net.Conn, insert *OpInsertMsg)
	HandleUpdate(c net.Conn, update *OpUpdateMsg)
	HandleDelete(c net.Conn, deleteMsg *OpDeleteMsg)

	DBNames() []string
	DB(name string) DB
}

type Collection

type Collection interface {
	Id(id string) interface{}
	All() []interface{}
	Match(pattern bson.M) []interface{}
	Insert(item interface{}) error
	Delete(pattern bson.M, limit int) int
}

type DB

type DB interface {
	Empty() bool
	CNames() []string
	C(name string) Collection

	LastError() interface{}
	SetLastError(doc interface{})
}

type DeleteFlags

type DeleteFlags int32
type Header struct {
	Length     int32
	RequestID  int32
	ResponseTo int32
	OpCode     OpCode
	Contents   []byte
}

func (*Header) Read

func (h *Header) Read(r io.Reader) error

func (*Header) Write

func (h *Header) Write(w io.Writer) error

type InsertFlags

type InsertFlags int32

type MemoryBackend

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

func NewMemoryBackend

func NewMemoryBackend(t *tomb.Tomb) *MemoryBackend

func (*MemoryBackend) DB

func (b *MemoryBackend) DB(name string) DB

func (*MemoryBackend) DBNames

func (b *MemoryBackend) DBNames() (result []string)

func (*MemoryBackend) HandleDelete

func (b *MemoryBackend) HandleDelete(c net.Conn, deleteMsg *OpDeleteMsg)

func (*MemoryBackend) HandleInsert

func (b *MemoryBackend) HandleInsert(c net.Conn, insert *OpInsertMsg)

func (*MemoryBackend) HandleQuery

func (b *MemoryBackend) HandleQuery(c net.Conn, query *OpQueryMsg)

func (*MemoryBackend) HandleUpdate

func (b *MemoryBackend) HandleUpdate(c net.Conn, update *OpUpdateMsg)

type MemoryCollection

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

func (*MemoryCollection) All

func (c *MemoryCollection) All() (result []interface{})

func (*MemoryCollection) Delete

func (c *MemoryCollection) Delete(pattern bson.M, limit int) int

func (*MemoryCollection) Id

func (c *MemoryCollection) Id(id string) interface{}

func (*MemoryCollection) Insert

func (c *MemoryCollection) Insert(doc interface{}) error

func (*MemoryCollection) Match

func (c *MemoryCollection) Match(pattern bson.M) (result []interface{})

type MemoryDB

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

func NewMemoryDB

func NewMemoryDB() *MemoryDB

func (*MemoryDB) C

func (db *MemoryDB) C(name string) Collection

func (*MemoryDB) CNames

func (db *MemoryDB) CNames() (result []string)

func (*MemoryDB) Empty

func (db *MemoryDB) Empty() bool

func (*MemoryDB) LastError

func (db *MemoryDB) LastError() interface{}

func (*MemoryDB) SetLastError

func (db *MemoryDB) SetLastError(doc interface{})

type OpCode

type OpCode int32

type OpDeleteMsg

type OpDeleteMsg struct {
	*Header

	// "dbname.collectionname"
	FullCollectionName string

	// Bit vector of update options.
	Flags DeleteFlags

	// Selector matches the documents to delete.
	Selector bson.M
	// contains filtered or unexported fields
}

func NewOpDeleteMsg

func NewOpDeleteMsg(h *Header) (*OpDeleteMsg, error)

type OpInsertMsg

type OpInsertMsg struct {
	*Header

	// Bit vector of query options.
	Flags InsertFlags
	// The full name of the collection.
	FullCollectionName string
	// One or more documents to insert into the collection.
	Docs []bson.M
}

func NewOpInsertMsg

func NewOpInsertMsg(h *Header) (*OpInsertMsg, error)

type OpQueryMsg

type OpQueryMsg struct {
	*Header

	// Bit vector of query options.
	Flags QueryFlags
	// The full name of a collection.
	FullCollectionName string
	// Number of documents to skip.
	NumberToSkip int32
	// Number of documents to return in the first OP_REPLY batch.
	NumberToReturn int32
	// Query object.  See below for details.
	Doc bson.D
	// Optional. Selector indicating the fields to return.
	ReturnFieldsSelector bson.D
}

func NewOpQueryMsg

func NewOpQueryMsg(h *Header) (*OpQueryMsg, error)

func (*OpQueryMsg) Command

func (msg *OpQueryMsg) Command() (cmd string, arg interface{})

func (*OpQueryMsg) Get

func (msg *OpQueryMsg) Get(key string) (interface{}, bool)

type OpReplyMsg

type OpReplyMsg struct {
	*Header

	// Bit vector - see details below.
	ResponseFlags int32
	// Cursor id if client needs to do get more's.
	CursorID int64
	// Where in the cursor this reply is starting.
	StartingFrom int32
	// Number of documents in the reply.
	NumberReturned int32
	Docs           []interface{}
	// contains filtered or unexported fields
}

func NewOpReplyMsg

func NewOpReplyMsg(responseTo int32, docs ...interface{}) *OpReplyMsg

func (*OpReplyMsg) Write

func (msg *OpReplyMsg) Write(w io.Writer) error

type OpUpdateMsg

type OpUpdateMsg struct {
	*Header

	// "dbname.collectionname"
	FullCollectionName string
	// Bit vector of update options.
	Flags UpdateFlags
	// Selector is the query to select the document.
	Selector bson.M
	// Update is the document update specification.
	Update bson.M
	// contains filtered or unexported fields
}

func NewOpUpdateMsg

func NewOpUpdateMsg(h *Header) (*OpUpdateMsg, error)

type QueryFlags

type QueryFlags int32

type Server

type Server struct {
	Backend Backend
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ln net.Listener, path string) (*Server, error)

func NewServerAddr

func NewServerAddr(netname, addr, storePath string) (*Server, error)

func (*Server) Start

func (s *Server) Start()

func (*Server) Stop

func (s *Server) Stop()

func (*Server) Wait

func (s *Server) Wait() error

type TikvBackend

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

func NewTikvBackend

func NewTikvBackend(t *tomb.Tomb, path string) (*TikvBackend, error)

func (*TikvBackend) DB

func (b *TikvBackend) DB(name string) DB

func (*TikvBackend) DBNames

func (b *TikvBackend) DBNames() (result []string)

func (*TikvBackend) HandleDelete

func (b *TikvBackend) HandleDelete(c net.Conn, deleteMsg *OpDeleteMsg)

func (*TikvBackend) HandleInsert

func (b *TikvBackend) HandleInsert(c net.Conn, insert *OpInsertMsg)

func (*TikvBackend) HandleQuery

func (b *TikvBackend) HandleQuery(c net.Conn, query *OpQueryMsg)

func (*TikvBackend) HandleUpdate

func (b *TikvBackend) HandleUpdate(c net.Conn, update *OpUpdateMsg)

TODO: implement it.

type TikvCollection

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

func (*TikvCollection) All

func (c *TikvCollection) All() (result []interface{})

TODO: implement it.

func (*TikvCollection) Delete

func (c *TikvCollection) Delete(pattern bson.M, limit int) int

TODO: implement it.

func (*TikvCollection) Id

func (c *TikvCollection) Id(id string) interface{}

TODO: implement it.

func (*TikvCollection) Insert

func (c *TikvCollection) Insert(doc interface{}) error

func (*TikvCollection) Match

func (c *TikvCollection) Match(pattern bson.M) []interface{}

type TikvDB

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

func NewTikvDB

func NewTikvDB(s kv.Storage) *TikvDB

func (*TikvDB) C

func (db *TikvDB) C(name string) Collection

func (*TikvDB) CNames

func (db *TikvDB) CNames() (result []string)

func (*TikvDB) Empty

func (db *TikvDB) Empty() bool

func (*TikvDB) LastError

func (db *TikvDB) LastError() interface{}

func (*TikvDB) SetLastError

func (db *TikvDB) SetLastError(doc interface{})

type UpdateFlags

type UpdateFlags int32

type WriteResult

type WriteResult struct {
	N               int         `bson:"n"`
	UpdatedExisting bool        `bson:"updatedExisting"`
	Upserted        interface{} `bson:"upserted"`
}

Jump to

Keyboard shortcuts

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