Unverified Commit 70c8911d authored by Adin Schmahmann's avatar Adin Schmahmann Committed by GitHub

Merge pull request #23 from ipfs/feat/ds-update

update datastore Interface
parents 0ebe79f8 4bdddbfb
...@@ -2,12 +2,8 @@ github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJY ...@@ -2,12 +2,8 @@ github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJY
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/ipfs/go-datastore v0.0.1 h1:AW/KZCScnBWlSb5JbnEnLKFWXL224LBEh/9KXXOrUms= github.com/ipfs/go-datastore v0.3.0 h1:9au0tYi/+n7xeUnGHG6davnS8x9hWbOzP/388Vx3CMs=
github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= github.com/ipfs/go-datastore v0.3.0/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-datastore v0.1.0 h1:TOxI04l8CmO4zGtesENhzm4PwkFwJXY3rKiYaaMf9fI=
github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore v0.1.1 h1:F4k0TkTAZGLFzBOrVKDAvch6JZtuN4NHkfdcEZL50aI=
github.com/ipfs/go-datastore v0.1.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg=
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
......
...@@ -32,6 +32,11 @@ func New(prefix string, ds datastore.Datastore) *measure { ...@@ -32,6 +32,11 @@ func New(prefix string, ds datastore.Datastore) *measure {
putSize: metrics.New(prefix+".put.size_bytes", putSize: metrics.New(prefix+".put.size_bytes",
"Size distribution of stored byte slices").Histogram(datastoreSizeBuckets), "Size distribution of stored byte slices").Histogram(datastoreSizeBuckets),
syncNum: metrics.New(prefix+".sync_total", "Total number of Datastore.Sync calls").Counter(),
syncErr: metrics.New(prefix+".sync.errors_total", "Number of errored Datastore.Sync calls").Counter(),
syncLatency: metrics.New(prefix+".sync.latency_seconds",
"Latency distribution of Datastore.Sync calls").Histogram(datastoreLatencyBuckets),
getNum: metrics.New(prefix+".get_total", "Total number of Datastore.Get calls").Counter(), getNum: metrics.New(prefix+".get_total", "Total number of Datastore.Get calls").Counter(),
getErr: metrics.New(prefix+".get.errors_total", "Number of errored Datastore.Get calls").Counter(), getErr: metrics.New(prefix+".get.errors_total", "Number of errored Datastore.Get calls").Counter(),
getLatency: metrics.New(prefix+".get.latency_seconds", getLatency: metrics.New(prefix+".get.latency_seconds",
...@@ -106,6 +111,10 @@ type measure struct { ...@@ -106,6 +111,10 @@ type measure struct {
putLatency metrics.Histogram putLatency metrics.Histogram
putSize metrics.Histogram putSize metrics.Histogram
syncNum metrics.Counter
syncErr metrics.Counter
syncLatency metrics.Histogram
getNum metrics.Counter getNum metrics.Counter
getErr metrics.Counter getErr metrics.Counter
getLatency metrics.Histogram getLatency metrics.Histogram
...@@ -173,6 +182,16 @@ func (m *measure) Put(key datastore.Key, value []byte) error { ...@@ -173,6 +182,16 @@ func (m *measure) Put(key datastore.Key, value []byte) error {
return err return err
} }
func (m *measure) Sync(prefix datastore.Key) error {
defer recordLatency(m.syncLatency, time.Now())
m.syncNum.Inc()
err := m.backend.Sync(prefix)
if err != nil {
m.syncErr.Inc()
}
return err
}
func (m *measure) Get(key datastore.Key) (value []byte, err error) { func (m *measure) Get(key datastore.Key) (value []byte, err error) {
defer recordLatency(m.getLatency, time.Now()) defer recordLatency(m.getLatency, time.Now())
m.getNum.Inc() m.getNum.Inc()
......
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