update the triplestore interface and local replication
This commit is contained in:
parent
768ca5c36f
commit
929b4f539b
2 changed files with 17 additions and 4 deletions
|
|
@ -70,6 +70,14 @@ type TripleStore interface {
|
||||||
// Returns the number of triples currently stored.
|
// Returns the number of triples currently stored.
|
||||||
Size() int64
|
Size() int64
|
||||||
|
|
||||||
|
// The last replicated transaction ID that this triplestore has verified.
|
||||||
|
Horizon() int64
|
||||||
|
|
||||||
|
// Inform the triplestore of a new replication strategy. Happens at startup and,
|
||||||
|
// perhaps in the future, if replication changes mid-run. Writes without any replication
|
||||||
|
// strategy are not allowed.
|
||||||
|
SetReplication(Replication)
|
||||||
|
|
||||||
// Creates a fixed iterator which can compare Values
|
// Creates a fixed iterator which can compare Values
|
||||||
FixedIterator() FixedIterator
|
FixedIterator() FixedIterator
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@
|
||||||
package local
|
package local
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/cayley/graph"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/google/cayley/graph"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LocalReplication struct {
|
type LocalReplication struct {
|
||||||
|
|
@ -25,7 +26,7 @@ type LocalReplication struct {
|
||||||
mut sync.Mutex
|
mut sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocalReplication(ts graph.TripleStore, opts graph.Options) (*LocalReplication, error) {
|
func NewLocalReplication(ts graph.TripleStore, opts graph.Options) (graph.Replication, error) {
|
||||||
rep := &LocalReplication{lastId: ts.Horizon(), ts: ts}
|
rep := &LocalReplication{lastId: ts.Horizon(), ts: ts}
|
||||||
ts.SetReplication(rep)
|
ts.SetReplication(rep)
|
||||||
return rep, nil
|
return rep, nil
|
||||||
|
|
@ -44,8 +45,12 @@ func (l *LocalReplication) GetLastId() int64 {
|
||||||
return l.lastId
|
return l.lastId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LocalReplication) Replicate([]*graph.Transaction) {}
|
func (l *LocalReplication) Replicate([]*graph.Transaction) {
|
||||||
func (l *LocalReplication) RequestTransactionRange(int64, int64) {}
|
// Noop, single-machines don't replicate out anywhere.
|
||||||
|
}
|
||||||
|
func (l *LocalReplication) RequestTransactionRange(int64, int64) {
|
||||||
|
// Single machines also can't catch up.
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
graph.RegisterReplication("local", NewLocalReplication)
|
graph.RegisterReplication("local", NewLocalReplication)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue