mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Merge pull request #94 from prometheus/refactor/persistence/interface-cleanups
Remove Cruft from Storage Interfaces
This commit is contained in:
commit
43a7ccd5be
|
@ -19,13 +19,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Pair struct {
|
|
||||||
Left []byte
|
|
||||||
Right []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type EachFunc func(pair *Pair)
|
|
||||||
|
|
||||||
// Persistence models a key-value store for bytes that supports various
|
// Persistence models a key-value store for bytes that supports various
|
||||||
// additional operations.
|
// additional operations.
|
||||||
type Persistence interface {
|
type Persistence interface {
|
||||||
|
@ -51,8 +44,6 @@ type Persistence interface {
|
||||||
ForEach(decoder storage.RecordDecoder, filter storage.RecordFilter, operator storage.RecordOperator) (scannedEntireCorpus bool, err error)
|
ForEach(decoder storage.RecordDecoder, filter storage.RecordFilter, operator storage.RecordOperator) (scannedEntireCorpus bool, err error)
|
||||||
// Commit applies the Batch operations to the database.
|
// Commit applies the Batch operations to the database.
|
||||||
Commit(Batch) error
|
Commit(Batch) error
|
||||||
// Pending removal.
|
|
||||||
GetAll() ([]Pair, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Batch models a pool of mutations for the database that can be committed
|
// Batch models a pool of mutations for the database that can be committed
|
||||||
|
|
|
@ -185,29 +185,6 @@ func (l *LevelDBPersistence) Commit(b raw.Batch) (err error) {
|
||||||
return l.storage.Write(l.writeOptions, batch.batch)
|
return l.storage.Write(l.writeOptions, batch.batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LevelDBPersistence) GetAll() (pairs []raw.Pair, err error) {
|
|
||||||
snapshot := l.storage.NewSnapshot()
|
|
||||||
defer l.storage.ReleaseSnapshot(snapshot)
|
|
||||||
readOptions := levigo.NewReadOptions()
|
|
||||||
defer readOptions.Close()
|
|
||||||
|
|
||||||
readOptions.SetSnapshot(snapshot)
|
|
||||||
iterator := l.storage.NewIterator(readOptions)
|
|
||||||
defer iterator.Close()
|
|
||||||
iterator.SeekToFirst()
|
|
||||||
|
|
||||||
for iterator := iterator; iterator.Valid(); iterator.Next() {
|
|
||||||
pairs = append(pairs, raw.Pair{Left: iterator.Key(), Right: iterator.Value()})
|
|
||||||
|
|
||||||
err = iterator.GetError()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *iteratorCloser) Close() (err error) {
|
func (i *iteratorCloser) Close() (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if i.storage != nil {
|
if i.storage != nil {
|
||||||
|
|
Loading…
Reference in a new issue