Commit b9346d07 authored by Jeromy's avatar Jeromy

betterify the everything

parent 6b0bf4f6
......@@ -3,6 +3,7 @@
package measure
import (
"io"
"time"
"github.com/jbenet/go-datastore"
......@@ -18,11 +19,6 @@ const (
maxSize = int64(1 << 32)
)
type DatastoreCloser interface {
datastore.Datastore
Close() error
}
// New wraps the datastore, providing metrics on the operations. The
// metrics are registered with names starting with prefix and a dot.
//
......@@ -84,7 +80,6 @@ type measure struct {
}
var _ datastore.Datastore = (*measure)(nil)
var _ DatastoreCloser = (*measure)(nil)
func recordLatency(h *metrics.Histogram, start time.Time) {
elapsed := time.Now().Sub(start) / time.Microsecond
......@@ -159,7 +154,7 @@ type measuredBatch struct {
}
func (m *measure) Batch() (datastore.Batch, error) {
bds, ok := m.backend.(datastore.BatchingDatastore)
bds, ok := m.backend.(datastore.Batching)
if !ok {
return nil, datastore.ErrBatchUnsupported
}
......@@ -245,5 +240,9 @@ func (m *measure) Close() error {
m.queryNum.Remove()
m.queryErr.Remove()
m.queryLatency.Remove()
if c, ok := m.backend.(io.Closer); ok {
return c.Close()
}
return nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment