// Copyright 2014, 2015 by Sascha L. Teichmann // Use of this source code is governed by the MIT license // that can be found in the LICENSE file. package main type ( // 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. Block struct { Key []byte Data []byte } // Session is a database session. Session interface { // 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 } // Backend is interface representing a database. Backend interface { // NewSession opens a new session. NewSession() (Session, error) // Shutdown shuts down the database server. Shutdown() error } )