Documentation ¶
Overview ¶
Package sinkdb provides a strongly consistent key-value store.
Index ¶
- Variables
- type DB
- func (db *DB) Close() error
- func (db *DB) Exec(ctx context.Context, ops ...Op) error
- func (db *DB) Get(ctx context.Context, key string, v proto.Message) (Version, error)
- func (db *DB) GetStale(key string, v proto.Message) (Version, error)
- func (db *DB) Ping() error
- func (db *DB) RaftService() *raft.Service
- type Op
- type Version
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("transaction conflict")
ErrConflict is returned by Exec when an instruction was not completed because its preconditions were not met.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB provides access to an opened kv store.
func (*DB) Close ¶
Close closes the database handle releasing its resources. It is the caller's responsibility to ensure that there are no concurrent database operations in flight. Close is idempotent.
All other methods have undefined behavior on a closed DB.
func (*DB) Get ¶
Get performs a linearizable read of the provided key. The read value is unmarshalled into v.
func (*DB) GetStale ¶
GetStale performs a non-linearizable read of the provided key. The value may be stale. The read value is unmarshalled into v.
func (*DB) RaftService ¶
RaftService returns the raft service used for replication.
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op represents a change to the data store. Each Op starts with conditions, boolean predicates over existing stored data. If all conditions return true, the Op is said to be satisfied. It then results in zero or more effects, mutations to apply to the data. If an Op is unsatisfied, it has no effect. The zero value of Op is a valid operation with no conditions (it is always satisfied) and no effects.
func AddAllowedMember ¶
AddAllowedMember configures sinkdb to allow the provided address to participate in Raft.
func All ¶
All encodes the atomic application of all its arguments.
The returned Op is satisfied if all arguments would be satisfied. Its effects (if satisfied) are the effects of the arguments.
func Error ¶
Error returns an Op representing an error condition. Exec will return err, and have no effect, when the returned Op is executed. If err is nil, Error returns the zero Op.
func IfNotExists ¶
IfNotExists encodes a conditional to make an instruction successful only if the provided key does not exist.
func IfNotModified ¶
IfNotModified encodes a conditional to make an instruction successful only if the version stored in v's key matches v.
If v.Exists() is false, IfNotModified(v) is equivalent to IfNotExists(v.Key()).