Commit d3bb1868 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Cosmetics

parent 149187b4
......@@ -305,7 +305,7 @@ func (e encoding) asTuple(xt interface{}) (tuple, bool) {
}
// xuint64Unpack tries to decode packed 8-byte string as bigendian uint64
// xuint64Unpack tries to retrieve packed 8-byte string as bigendian uint64.
func (e encoding) xuint64Unpack(xv interface{}) (uint64, bool) {
switch e {
default:
......@@ -332,9 +332,10 @@ func (e encoding) xuint64Unpack(xv interface{}) (uint64, bool) {
return binary.BigEndian.Uint64(v), true
}
}
}
// xuint64Pack packs v into big-endian 8-byte string
// xuint64Pack packs v into big-endian 8-byte string.
func (e encoding) xuint64Pack(v uint64) interface{} {
var b [8]byte
binary.BigEndian.PutUint64(b[:], v)
......
......@@ -35,6 +35,7 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
)
// zeo provides ZEO client.
type zeo struct {
link *zLink
......@@ -51,7 +52,11 @@ type zeo struct {
url string // we were opened via this
}
// zeo implements zodb.IStorageDriver.
var _ zodb.IStorageDriver = (*zeo)(nil)
// Sync implements zodb.IStorageDriver.
func (z *zeo) Sync(ctx context.Context) (head zodb.Tid, err error) {
defer func() {
if err != nil {
......@@ -75,6 +80,7 @@ func (z *zeo) Sync(ctx context.Context) (head zodb.Tid, err error) {
return head, nil
}
// Load implements zodb.IStorageDriver.
func (z *zeo) Load(ctx context.Context, xid zodb.Xid) (buf *mem.Buf, serial zodb.Tid, err error) {
defer func() {
if err != nil {
......@@ -106,6 +112,7 @@ func (z *zeo) Load(ctx context.Context, xid zodb.Xid) (buf *mem.Buf, serial zodb
return &mem.Buf{Data: data}, serial, nil
}
// Iterates implements zodb.IStorageDriver.
func (z *zeo) Iterate(ctx context.Context, tidMin, tidMax zodb.Tid) zodb.ITxnIterator {
panic("TODO")
}
......@@ -204,7 +211,7 @@ func ereplyf(addr, method, format string, argv ...interface{}) *errorUnexpectedR
}
}
// rpc returns rpc object handy to make calls/create errors
// rpc returns rpc object handy to make calls/create errors.
func (z *zeo) rpc(method string) rpc {
return rpc{zlink: z.link, method: method}
}
......@@ -214,7 +221,7 @@ type rpc struct {
method string
}
// rpcExcept represents generic exception
// rpcExcept represents generic exception.
type rpcExcept struct {
exc string
argv tuple
......@@ -464,7 +471,7 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
}
}
lastTid, ok := zlink.enc.asTid(xlastTid) // XXX -> xlastTid -> scan
lastTid, ok := zlink.enc.asTid(xlastTid)
if !ok {
return nil, zodb.InvalidTid, rpc.ereplyf("got %v; expect tid", xlastTid)
}
......
......@@ -37,13 +37,11 @@ import (
"lab.nexedi.com/kirr/go123/xsync"
)
const pktHeaderLen = 4
// we can speak this protocol versions
var protoVersions = []string{
"3101", // last in ZEO3 series
"4", // no longer call load.
"5", // current in ZEO5 series.
"5", // current in ZEO5 series (no serialnos, ...).
}
......@@ -309,6 +307,9 @@ func (zl *zLink) reply(msgid int64, res interface{}) (err error) {
// ---- raw IO ----
// packet = {size(u32), data}
const pktHeaderLen = 4
// pktBuf is buffer with packet data.
//
// alloc via allocPkb and free via pkb.Free.
......@@ -376,7 +377,7 @@ func (zl *zLink) sendPkt(pkb *pktBuf) error {
// recvPkt receives 1 raw ZEO packet.
//
// the packet returned contains both header and payload.
// XXX almost dump from NEO.
// XXX almost dup from NEO.
func (zl *zLink) recvPkt() (*pktBuf, error) {
pkb := allocPkb()
data := pkb.data[:cap(pkb.data)]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment