datastore no longer implements logstore (#1013)

* datastore no longer implements logstore

the underlying implementation of our sql store implements both the datastore
and the logstore interface, however going forward we are likely to encounter
datastore implementers that would mock out the logstore interface and not use
its methods - signalling a poor interface. this remedies that, now they are 2
completely separate things, which our sqlstore happens to implement both of.

related to some recent changes around wrapping, this keeps the imposed metrics
and validation wrapping of a servers logstore and datastore, just moving it
into New instead of in the opts - this is so that a user can have the
underlying datastore in order to set the logstore to it, since wrapping it in
a validator/metrics would render it no longer a logstore implementer (i.e.
validate datastore doesn't implement the logstore interface), we need to do
this after setting the logstore to the datastore if one wasn't provided
explicitly.

* splits logstore and datastore metrics & validation logic
* `make test` should be `make full-test` always. got rid of that so that
nobody else has to wait for CI to blow up on them after the tests pass locally
ever again.

* fix new tests
This commit is contained in:
Reed Allman
2018-06-04 00:08:16 -07:00
committed by GitHub
parent e0425abd19
commit 00c29b8bf3
17 changed files with 250 additions and 127 deletions

View File

@@ -2,7 +2,6 @@ package datastoreutil
import (
"context"
"io"
"go.opencensus.io/trace"
@@ -84,36 +83,6 @@ func (m *metricds) RemoveRoute(ctx context.Context, appID string, routePath stri
return m.ds.RemoveRoute(ctx, appID, routePath)
}
func (m *metricds) InsertCall(ctx context.Context, call *models.Call) error {
ctx, span := trace.StartSpan(ctx, "ds_insert_call")
defer span.End()
return m.ds.InsertCall(ctx, call)
}
func (m *metricds) GetCall(ctx context.Context, appName, callID string) (*models.Call, error) {
ctx, span := trace.StartSpan(ctx, "ds_get_call")
defer span.End()
return m.ds.GetCall(ctx, appName, callID)
}
func (m *metricds) GetCalls(ctx context.Context, filter *models.CallFilter) ([]*models.Call, error) {
ctx, span := trace.StartSpan(ctx, "ds_get_calls")
defer span.End()
return m.ds.GetCalls(ctx, filter)
}
func (m *metricds) InsertLog(ctx context.Context, appName, callID string, callLog io.Reader) error {
ctx, span := trace.StartSpan(ctx, "ds_insert_log")
defer span.End()
return m.ds.InsertLog(ctx, appName, callID, callLog)
}
func (m *metricds) GetLog(ctx context.Context, appName, callID string) (io.Reader, error) {
ctx, span := trace.StartSpan(ctx, "ds_get_log")
defer span.End()
return m.ds.GetLog(ctx, appName, callID)
}
// instant & no context ;)
func (m *metricds) GetDatabase() *sqlx.DB { return m.ds.GetDatabase() }

View File

@@ -132,14 +132,6 @@ func (v *validator) RemoveRoute(ctx context.Context, appID string, routePath str
return v.Datastore.RemoveRoute(ctx, appID, routePath)
}
// callID will never be empty.
func (v *validator) GetCall(ctx context.Context, appName, callID string) (*models.Call, error) {
if callID == "" {
return nil, models.ErrDatastoreEmptyCallID
}
return v.Datastore.GetCall(ctx, appName, callID)
}
// GetDatabase returns the underlying sqlx database implementation
func (v *validator) GetDatabase() *sqlx.DB {
return v.Datastore.GetDatabase()