Documentation
¶
Index ¶
- Constants
- Variables
- func Gblob(buf []byte) ([]byte, []byte)
- func Gint16(buf []byte) (uint16, []byte)
- func Gint32(buf []byte) (uint32, []byte)
- func Gint64(buf []byte) (uint64, []byte)
- func Gint8(buf []byte) (uint8, []byte)
- func Gstr(buf []byte) (string, []byte)
- func Pblob(val []byte, buf []byte) []byte
- func Pint16(val uint16, buf []byte) []byte
- func Pint32(val uint32, buf []byte) []byte
- func Pint64(val uint64, buf []byte) []byte
- func Pint8(val uint8, buf []byte) []byte
- func Pstr(val string, buf []byte) []byte
- type AtomicHop
- type CreatorHop
- type Entry
- type GetterHop
- type Hop
- type KHop
- func (h *KHop) AddEntry(key string, val []byte, ops interface{}) (e *Entry, err error)
- func (h *KHop) Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)
- func (h *KHop) Create(key, flags string, value []byte) (ver uint64, err error)
- func (h *KHop) ExportEntries(match func(key string) bool) (es []byte)
- func (h *KHop) FindEntry(key string) (ops interface{})
- func (h *KHop) Get(key string, version uint64) (ver uint64, val []byte, err error)
- func (h *KHop) ImportKeys(es []byte, replace bool) (rejected []string, err error)
- func (h *KHop) InitKHop()
- func (h *KHop) NumEntries() (n int)
- func (h *KHop) Remove(key string) (err error)
- func (h *KHop) RemoveEntry(key string) (err error)
- func (h *KHop) Set(key string, value []byte) (ver uint64, err error)
- func (h *KHop) TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)
- func (h *KHop) VisitEntries(visit func(key string, e *Entry))
- type Log
- type Logger
- type MHop
- func (m *MHop) AddAfter(pattern string, exact bool, cutprefix bool, hop interface{}) error
- func (m *MHop) AddBefore(pattern string, exact bool, cutprefix bool, hop interface{}) error
- func (m *MHop) Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)
- func (m *MHop) Create(key, flags string, value []byte) (ver uint64, err error)
- func (m *MHop) Get(key string, version uint64) (ver uint64, val []byte, err error)
- func (m *MHop) Remove(key string) (err error)
- func (m *MHop) Set(key string, value []byte) (ver uint64, err error)
- func (m *MHop) SetDefault(dflt interface{})
- func (m *MHop) String() string
- func (m *MHop) TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)
- type SetterHop
- type TestSetterHop
Constants ¶
const ( Any = 0 Lowest = 1 Highest = Newest - 1 Newest = 0x7FFFFFFFFFFFFFFF Removed = 0x8000000000000000 PastNewest = 0xFFFFFFFFFFFFFFFF )
Version values
const ( // Atomically add the specified value to the current value. // The current value and the specified one need to be the same length. // Supports byte array lengths of 1, 2, 4, and 8, assumes little-endian // order, and converts them to the appropriate unsigned integer. Add = iota // Atomically subtracts the specified value from the current value. // Same requirements as AtomicAdd. Sub // If the specified value is nil, atomically set/clear one bit in the // current value that was zero before. Returns two byte arrays: the // new value of the entry, and the 'address' of the bit set/cleared as // a 32-bit integer, represented as 4-byte array. BitSet BitClear // Atomically append the specified value to the end of the current value Append // Atomically remove all matches of the specified value from the current // value. If there are no matches, the entry's value and version are // not modified Remove // Atomically replace all matches of the first specified value with the // second specified value. If there are no matches, the entry's value // and version are not modified Replace )
Atomic Set operations
Variables ¶
var Eexist = errors.New("key exists")
var Enoent = errors.New("key doesn't exist")
var Eperm = errors.New("permission denied")
var Eremoved = errors.New("key removed")
Functions ¶
Types ¶
type CreatorHop ¶
type CreatorHop interface {
Create(key, flags string, value []byte) (ver uint64, err error)
Remove(key string) (err error)
}
Separate interfaces for each operation
type Entry ¶
type Hop ¶
type Hop interface {
// Create add a new entry to the key-value store. The content of the
// flags parameter is implementation dependent
Create(key, flags string, value []byte) (ver uint64, err error)
// Removes an entry from the key-value store.
Remove(key string) (err error)
// Retrieves the value for the specified key and version. If necessary,
// the call waits until the entry's version becomes greater than the
// specified. Version 0 (Any) returns immediately any value available.
// Version 2^31-1 (Newest) tries to return the most up-to-date value.
// Version 2^32-1 (PastNewest) waits until a new value is set and
// returns it. Returns the version and the value.
Get(key string, version uint64) (ver uint64, val []byte, err error)
// Stores new value for the specified key. Returns the new version.
Set(key string, value []byte) (ver uint64, err error)
// Checks if the entry's current version and value match the specified
// oldversion and oldvalue. If true, stores the new value and returns
// the new version. If oldversion is Any, doesn't compare the versions.
// If oldvalue is nil, doesn't compare the values.
// TestSet(key, Any, nil, val) is equivalent to Set(key, val)
TestSet(key string, oldversion uint64, oldvalue, value []byte) (ver uint64, val []byte, err error)
// Atomically executes the specified operation on the entry's value.
// Returns the new version and list of values. Number of specified
// values, as well as the number of returned ones depends on the
// operation type. If any values are returned, the first value in the
// list should be the new value of the entry
Atomic(key string, op uint16, values [][]byte) (ver uint64, vals [][]byte, err error)
}
type KHop ¶
func (*KHop) AddEntry ¶
If ops is a pointer to a struct that has field of type Entry, that entry is initialized and its value is put in the entries map.
func (*KHop) ExportEntries ¶
Exports entries that match to a byte array, that can be used by ImportKeys. The exported entries are removed from the datastore and if there are waiters on their values, they are informed. At the moment, we don't support "special" entries (i.e. entries that have ops != nil).
func (*KHop) ImportKeys ¶
imports the keys previously exported by ExportEntries. If replace is true overwrites existing keys. If it is false, returns the list of keys that weren't imported because of collisions. At the moment, we don't support "special" entries (i.e. entries that have ops != nil).
func (*KHop) NumEntries ¶
func (*KHop) RemoveEntry ¶
func (*KHop) VisitEntries ¶
Calls the visit function for each entry. Use carefully, the h read lock is held while the function is called.
Directories
¶
| Path | Synopsis |
|---|---|
|
bench
command
|
|
|
chordsrv
command
|
|
|
bench
command
|
|
|
d2hopsrv
command
|
|
|
dhopsrv
command
|
|
|
kcd2hop
command
|
|
|
kchopsrv
command
|
|
|
ldd2hop
command
|
|
|
ldhopsrv
command
|
|
|
hopclnt
The clnt package provides definitions and functions used to implement a Hop client.
|
The clnt package provides definitions and functions used to implement a Hop client. |
|
hopsrv
The srv package provides definitions and functions used to implement a remote Hop server.
|
The srv package provides definitions and functions used to implement a remote Hop server. |
|
shopsrv
command
|