mtsatellite/cmd/mtredisalize/backend.go

46 lines
1.5 KiB
Go
Raw Normal View History

// Copyright 2014, 2015 by Sascha L. Teichmann
2014-08-03 15:59:56 +02:00
// Use of this source code is governed by the MIT license
// that can be found in the LICENSE file.
package main
type (
2024-01-07 10:54:21 +01:00
// block is the essential transfer unit from to the database.
// Key is the serialized spatial position.
// Data is the serialized from of the corresponding block data.
2024-01-07 10:54:21 +01:00
block struct {
Key []byte
Data []byte
}
2024-01-07 10:54:21 +01:00
// session is a database session.
session interface {
// del deletes a block by a given key.
del(hash, key []byte) (bool, error)
// fetch fetches the block data for a given position.
fetch(hash, key []byte) ([]byte, error)
// inTransaction returns true if a transaction is running.
inTransaction() bool
// store stores a block with a given position and data.
store(hash, key, value []byte) (bool, error)
// allKeys returns all keys in the database.
allKeys(hash []byte, done <-chan struct{}) (<-chan []byte, int, error)
// spatialQuery performs a box query between the positions first and second.
spatialQuery(hash, first, second []byte, done <-chan struct{}) (<-chan block, error)
// beginTransaction starts a transcation.
beginTransaction() error
// commitTransaction finishes a transaction.
commitTransaction() error
// close closes the database session.
close() error
}
2024-01-07 10:54:21 +01:00
// backend is the interface representing a database.
backend interface {
// newSession opens a new session.
newSession() (session, error)
// shutdown shuts down the database server.
shutdown() error
}
)