Documentation ¶
Overview ¶
The official client API of GoTable. GoTable is a high performance NoSQL database.
Index ¶
- Constants
- Variables
- type Addr
- type Call
- type Client
- type Context
- func (c *Context) Auth(password string) error
- func (c *Context) Client() *Client
- func (c *Context) DatabaseId() uint8
- func (c *Context) Del(tableId uint8, rowKey, colKey []byte, cas uint32) error
- func (c *Context) DumpDB() (DumpReply, error)
- func (c *Context) DumpMore(last DumpReply) (DumpReply, error)
- func (c *Context) DumpPivot(oneTable bool, tableId, colSpace uint8, rowKey, colKey []byte, score int64, ...) (DumpReply, error)
- func (c *Context) DumpTable(tableId uint8) (DumpReply, error)
- func (c *Context) Get(tableId uint8, rowKey, colKey []byte, cas uint32) (value []byte, score int64, retCas uint32, err error)
- func (c *Context) GoDel(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
- func (c *Context) GoGet(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
- func (c *Context) GoIncr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32, done chan *Call) (*Call, error)
- func (c *Context) GoMDel(args []DelArgs, done chan *Call) (*Call, error)
- func (c *Context) GoMGet(args []GetArgs, done chan *Call) (*Call, error)
- func (c *Context) GoMIncr(args []IncrArgs, done chan *Call) (*Call, error)
- func (c *Context) GoMSet(args []SetArgs, done chan *Call) (*Call, error)
- func (c *Context) GoPing(done chan *Call) (*Call, error)
- func (c *Context) GoScan(tableId uint8, rowKey []byte, asc bool, num int, done chan *Call) (*Call, error)
- func (c *Context) GoScanPivot(tableId uint8, rowKey, colKey []byte, asc bool, num int, done chan *Call) (*Call, error)
- func (c *Context) GoSet(tableId uint8, rowKey, colKey, value []byte, score int64, cas uint32, ...) (*Call, error)
- func (c *Context) GoZDel(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
- func (c *Context) GoZGet(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
- func (c *Context) GoZIncr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32, done chan *Call) (*Call, error)
- func (c *Context) GoZScan(tableId uint8, rowKey []byte, asc, orderByScore bool, num int, done chan *Call) (*Call, error)
- func (c *Context) GoZScanPivot(tableId uint8, rowKey, colKey []byte, score int64, asc, orderByScore bool, ...) (*Call, error)
- func (c *Context) GoZSet(tableId uint8, rowKey, colKey, value []byte, score int64, cas uint32, ...) (*Call, error)
- func (c *Context) GoZmDel(args []DelArgs, done chan *Call) (*Call, error)
- func (c *Context) GoZmGet(args []GetArgs, done chan *Call) (*Call, error)
- func (c *Context) GoZmIncr(args []IncrArgs, done chan *Call) (*Call, error)
- func (c *Context) GoZmSet(args []SetArgs, done chan *Call) (*Call, error)
- func (c *Context) Incr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32) (newValue []byte, newScore int64, err error)
- func (c *Context) MDel(args MDelArgs) ([]DelReply, error)
- func (c *Context) MGet(args MGetArgs) ([]GetReply, error)
- func (c *Context) MIncr(args MIncrArgs) ([]IncrReply, error)
- func (c *Context) MSet(args MSetArgs) ([]SetReply, error)
- func (c *Context) Ping() error
- func (c *Context) Scan(tableId uint8, rowKey []byte, asc bool, num int) (ScanReply, error)
- func (c *Context) ScanMore(last ScanReply) (ScanReply, error)
- func (c *Context) ScanPivot(tableId uint8, rowKey, colKey []byte, asc bool, num int) (ScanReply, error)
- func (c *Context) Set(tableId uint8, rowKey, colKey, value []byte, score int64, cas uint32) error
- func (c *Context) ZDel(tableId uint8, rowKey, colKey []byte, cas uint32) error
- func (c *Context) ZGet(tableId uint8, rowKey, colKey []byte, cas uint32) (value []byte, score int64, retCas uint32, err error)
- func (c *Context) ZIncr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32) (newValue []byte, newScore int64, err error)
- func (c *Context) ZScan(tableId uint8, rowKey []byte, asc, orderByScore bool, num int) (ScanReply, error)
- func (c *Context) ZScanPivot(tableId uint8, rowKey, colKey []byte, score int64, asc, orderByScore bool, ...) (ScanReply, error)
- func (c *Context) ZSet(tableId uint8, rowKey, colKey, value []byte, score int64, cas uint32) error
- func (c *Context) ZmDel(args MDelArgs) ([]DelReply, error)
- func (c *Context) ZmGet(args MGetArgs) ([]GetReply, error)
- func (c *Context) ZmIncr(args MIncrArgs) ([]IncrReply, error)
- func (c *Context) ZmSet(args MSetArgs) ([]SetReply, error)
- type CtrlContext
- type DelArgs
- type DelReply
- type DumpKV
- type DumpReply
- type GetArgs
- type GetReply
- type IncrArgs
- type IncrReply
- type MDelArgs
- type MGetArgs
- type MIncrArgs
- type MSetArgs
- type Pool
- type ScanKV
- type ScanReply
- type SetArgs
- type SetReply
Constants ¶
const ( EcNotExist = 1 // Key NOT exist EcOk = 0 // Success EcCasNotMatch = -1 // CAS not match, get new CAS and try again EcTempFail = -2 // Temporary failed, retry may fix this EcUnknownCmd = -10 // Unknown cmd EcAuthFailed = -11 // Authorize failed EcNoPrivilege = -12 // No access privilege EcWriteSlave = -13 // Can NOT write slave directly EcSlaveCas = -14 // Invalid CAS on slave for GET/MGET EcReadFail = -15 // Read failed EcWriteFail = -16 // Write failed EcDecodeFail = -17 // Decode request PKG failed EcInvDbId = -18 // Invalid DB ID (cannot be 255) EcInvRowKey = -19 // RowKey length should be [1 ~ 255] EcInvValue = -20 // Value length should be [0 ~ 1MB] EcInvPkgLen = -21 // Pkg length should be less than 2MB EcInvScanNum = -22 // Scan request number out of range EcScanEnded = -23 // Already scan/dump to end )
GoTable Error Code List
const Version = "1.0.3" // GoTable version
Variables ¶
var ( ErrShutdown = errors.New("connection is shutdown") ErrCallNotReady = errors.New("call not ready to reply") ErrClosedPool = errors.New("connection pool is closed") ErrNoValidAddr = errors.New("no valid address") )
var ( ErrCasNotMatch = initErr(EcCasNotMatch, "cas not match") ErrTempFail = initErr(EcTempFail, "temporary failed") ErrUnknownCmd = initErr(EcUnknownCmd, "unknown cmd") ErrAuthFailed = initErr(EcAuthFailed, "authorize failed") ErrNoPrivilege = initErr(EcNoPrivilege, "no access privilege") ErrWriteSlave = initErr(EcWriteSlave, "can not write slave directly") ErrSlaveCas = initErr(EcSlaveCas, "invalid cas on slave") ErrReadFail = initErr(EcReadFail, "read failed") ErrWriteFail = initErr(EcWriteFail, "write failed") ErrDecodeFail = initErr(EcDecodeFail, "decode request pkg failed") ErrInvDbId = initErr(EcInvDbId, "can not use admin db") ErrInvRowKey = initErr(EcInvRowKey, "row key length out of range") ErrInvValue = initErr(EcInvValue, "value length out of range") ErrInvPkgLen = initErr(EcInvPkgLen, "pkg length out of range") ErrInvScanNum = initErr(EcInvScanNum, "scan request number out of range") ErrScanEnded = initErr(EcScanEnded, "already scan/dump to end") )
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct { Done chan *Call // Reply channel // contains filtered or unexported fields }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a connection to GoTable server. It's safe to use in multiple goroutines.
func Dial ¶
Dial connects to the address on the named network of GoTable server.
Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), and "unix". For TCP networks, addresses have the form host:port. For Unix networks, the address must be a file system path.
It returns a connection Client to GoTable server.
func (*Client) NewContext ¶
Create a new client Context with selected dbId. All operations on the Context use the selected dbId.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Connection Context to GoTable server. It's safe to use in multiple goroutines.
func (*Context) DatabaseId ¶
Get the selected database ID of the Context.
func (*Context) Del ¶
Delete the key in default column space. CAS is 0 for normal cases. Use the CAS returned by GET if you want to "lock" the record.
func (*Context) DumpPivot ¶
func (c *Context) DumpPivot(oneTable bool, tableId, colSpace uint8, rowKey, colKey []byte, score int64, startUnitId, endUnitId uint16) (DumpReply, error)
Dump records from the pivot record. If oneTable is true, only dump the selected table. If oneTable is false, dump all tables in current DB(dbId). The pivot record is excluded from the reply.
func (*Context) Get ¶
func (c *Context) Get(tableId uint8, rowKey, colKey []byte, cas uint32) ( value []byte, score int64, retCas uint32, err error)
Get value&score of the key in default column space. Parameter CAS is Compare-And-Swap, 2 means read data on master and return a new CAS, 1 means read data on master machine but without a new CAS, 0 means read data on any machine without a new CAS. On cluster mode, routing to master machine is automatically, but on a normal master/slave mode it should be done manually. If CAS 1&2 sent to a slave machine, error will be returned. For most cases, set CAS as 0. Return value nil means key not exist.
func (*Context) GoDel ¶
func (c *Context) GoDel(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
Asynchronous DEL API.
func (*Context) GoGet ¶
func (c *Context) GoGet(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
Asynchronous GET API.
func (*Context) GoIncr ¶
func (c *Context) GoIncr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32, done chan *Call) (*Call, error)
Asynchronous INCR API.
func (*Context) GoScan ¶
func (c *Context) GoScan(tableId uint8, rowKey []byte, asc bool, num int, done chan *Call) (*Call, error)
Asynchronous SCAN API from MIN/MAX colKey.
func (*Context) GoScanPivot ¶
func (c *Context) GoScanPivot(tableId uint8, rowKey, colKey []byte, asc bool, num int, done chan *Call) (*Call, error)
Asynchronous SCAN API from pivot record.
func (*Context) GoSet ¶
func (c *Context) GoSet(tableId uint8, rowKey, colKey, value []byte, score int64, cas uint32, done chan *Call) (*Call, error)
Asynchronous SET API.
func (*Context) GoZDel ¶
func (c *Context) GoZDel(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
Asynchronous ZDEL API.
func (*Context) GoZGet ¶
func (c *Context) GoZGet(tableId uint8, rowKey, colKey []byte, cas uint32, done chan *Call) (*Call, error)
Asynchronous ZGET API.
func (*Context) GoZIncr ¶
func (c *Context) GoZIncr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32, done chan *Call) (*Call, error)
Asynchronous ZINCR API.
func (*Context) GoZScan ¶
func (c *Context) GoZScan(tableId uint8, rowKey []byte, asc, orderByScore bool, num int, done chan *Call) (*Call, error)
Asynchronous ZSCAN API from MIN/MAX colKey and score.
func (*Context) GoZScanPivot ¶
func (c *Context) GoZScanPivot(tableId uint8, rowKey, colKey []byte, score int64, asc, orderByScore bool, num int, done chan *Call) (*Call, error)
Asynchronous ZSCAN API from pivot record.
func (*Context) GoZSet ¶
func (c *Context) GoZSet(tableId uint8, rowKey, colKey, value []byte, score int64, cas uint32, done chan *Call) (*Call, error)
Asynchronous ZSET API.
func (*Context) Incr ¶
func (c *Context) Incr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32) (newValue []byte, newScore int64, err error)
Increase key/score in default column space. CAS is 0 for normal cases. Use the CAS returned by GET if you want to "lock" the record.
func (*Context) Scan ¶
Scan columns of rowKey in default column space from MIN/MAX colKey. If asc is true SCAN start from the MIN colKey, else SCAN from the MAX colKey. It replies at most num records.
func (*Context) ScanPivot ¶
func (c *Context) ScanPivot(tableId uint8, rowKey, colKey []byte, asc bool, num int) (ScanReply, error)
Scan columns of rowKey in default column space from pivot record. The colKey is the pivot record where scan starts. If asc is true SCAN in ASC order, else SCAN in DESC order. It replies at most num records. The pivot record is excluded from the reply.
func (*Context) Set ¶
Set key/value in default column space. CAS is 0 for normal cases. Use the CAS returned by GET if you want to "lock" the record.
func (*Context) ZDel ¶
Delete the key in "Z" sorted score column space. CAS is 0 for normal cases. Use the CAS returned by GET if you want to "lock" the record.
func (*Context) ZGet ¶
func (c *Context) ZGet(tableId uint8, rowKey, colKey []byte, cas uint32) ( value []byte, score int64, retCas uint32, err error)
Get value&score of the key in "Z" sorted score column space. Request and return parameters have the same meaning as the Get API.
func (*Context) ZIncr ¶
func (c *Context) ZIncr(tableId uint8, rowKey, colKey []byte, score int64, cas uint32) (newValue []byte, newScore int64, err error)
Increase key/score in "Z" sorted score column space. CAS is 0 for normal cases. Use the CAS returned by GET if you want to "lock" the record.
func (*Context) ZScan ¶
func (c *Context) ZScan(tableId uint8, rowKey []byte, asc, orderByScore bool, num int) (ScanReply, error)
Scan columns of rowKey in "Z" sorted score space from MIN/MAX colKey and score. If asc is true ZSCAN start from the MIN colKey and score, else ZSCAN from the MAX colKey and score. If orderByScore is true ZSCAN order by score+colKey, else ZSCAN order by colKey. It replies at most num records.
func (*Context) ZScanPivot ¶
func (c *Context) ZScanPivot(tableId uint8, rowKey, colKey []byte, score int64, asc, orderByScore bool, num int) (ScanReply, error)
Scan columns of rowKey in "Z" sorted score space from pivot record. The colKey and score is the pivot record where scan starts. If asc is true ZSCAN in ASC order, else ZSCAN in DESC order. If orderByScore is true ZSCAN order by score+colKey, else ZSCAN order by colKey. It replies at most num records. The pivot record is excluded from the reply.
func (*Context) ZSet ¶
Set key/value in "Z" sorted score column space. CAS is 0 for normal cases. Use the CAS returned by GET if you want to "lock" the record.
type CtrlContext ¶
type CtrlContext Context
Inner control context
func (*CtrlContext) DelUnit ¶ added in v1.0.3
func (c *CtrlContext) DelUnit(unitId uint16) error
Internal control command. DelUnit deletes one unit data.
func (*CtrlContext) Migrate ¶
func (c *CtrlContext) Migrate(host string, unitId uint16) error
Internal control command. Migrate moves one unit data to another server on the fly.
func (*CtrlContext) SlaveOf ¶
func (c *CtrlContext) SlaveOf(host string) error
Internal control command. SlaveOf can change the replication settings of a slave on the fly.
func (*CtrlContext) SlaveStatus ¶
func (c *CtrlContext) SlaveStatus(migration bool, unitId uint16) (int, error)
Internal control command. SlaveStatus reads migration/slave status.