diff --git a/clouddatastore/testsuite_test.go b/clouddatastore/testsuite_test.go index 8b3d828..290cbc3 100644 --- a/clouddatastore/testsuite_test.go +++ b/clouddatastore/testsuite_test.go @@ -170,7 +170,7 @@ func TestCloudDatastoreWithRPCRetryAndChaosRPCTestSuite(t *testing.T) { rpcretry.WithRetryLimit(10), rpcretry.WithMinBackoffDuration(1), rpcretry.WithMaxBackoffDuration(1), - rpcretry.WithLogf(func(ctx context.Context, format string, args ...interface{}) { + rpcretry.WithLogger(func(ctx context.Context, format string, args ...interface{}) { t.Logf(format, args...) }), ) diff --git a/dsmiddleware/rpcretry/option.go b/dsmiddleware/rpcretry/option.go index 3399497..290e5e2 100644 --- a/dsmiddleware/rpcretry/option.go +++ b/dsmiddleware/rpcretry/option.go @@ -49,16 +49,22 @@ func (w *withMaxDoublings) Apply(rh *retryHandler) { rh.maxDoublings = w.maxDoublings } +// WithLogger creates a ClientOption that uses the specified logger. +func WithLogger(logf func(ctx context.Context, format string, args ...interface{})) RetryOption { + return &withLogger{logf} +} + // WithLogf creates a ClientOption that uses the specified logger. -// TODO rename to WithLogger +// +// Deprecated: use WithLogger instead. func WithLogf(logf func(ctx context.Context, format string, args ...interface{})) RetryOption { - return &withLogf{logf} + return WithLogger(logf) } -type withLogf struct { +type withLogger struct { logf func(ctx context.Context, format string, args ...interface{}) } -func (w *withLogf) Apply(rh *retryHandler) { +func (w *withLogger) Apply(rh *retryHandler) { rh.logf = w.logf } diff --git a/dsmiddleware/rpcretry/rpcretry_test.go b/dsmiddleware/rpcretry/rpcretry_test.go index 2034a55..a6945e4 100644 --- a/dsmiddleware/rpcretry/rpcretry_test.go +++ b/dsmiddleware/rpcretry/rpcretry_test.go @@ -100,7 +100,7 @@ func TestRPCRetry_Basic(t *testing.T) { }() rh := New( - WithLogf(logf), + WithLogger(logf), WithMinBackoffDuration(1), WithRetryLimit(4), ) @@ -217,7 +217,7 @@ func TestRPCRetry_Transaction(t *testing.T) { }() rh := New( - WithLogf(logf), + WithLogger(logf), WithMinBackoffDuration(1), WithRetryLimit(2), ) @@ -420,7 +420,7 @@ func TestRPCRetry_AllocateIDs(t *testing.T) { }() rh := New( - WithLogf(logf), + WithLogger(logf), WithMinBackoffDuration(1), WithRetryLimit(2), ) @@ -507,7 +507,7 @@ func TestRPCRetry_GetAll(t *testing.T) { }() rh := New( - WithLogf(logf), + WithLogger(logf), WithMinBackoffDuration(1), WithRetryLimit(2), ) @@ -648,7 +648,7 @@ func TestRPCRetry_Count(t *testing.T) { }() rh := New( - WithLogf(logf), + WithLogger(logf), WithMinBackoffDuration(1), WithRetryLimit(2), ) diff --git a/testsuite/dsmiddleware/rpcretry/rpcretry.go b/testsuite/dsmiddleware/rpcretry/rpcretry.go index 4a45d92..dc13800 100644 --- a/testsuite/dsmiddleware/rpcretry/rpcretry.go +++ b/testsuite/dsmiddleware/rpcretry/rpcretry.go @@ -49,7 +49,7 @@ func basic(ctx context.Context, t *testing.T, client datastore.Client) { }() rh := rpcretry.New( - rpcretry.WithLogf(logf), + rpcretry.WithLogger(logf), rpcretry.WithMinBackoffDuration(1), rpcretry.WithRetryLimit(4), ) @@ -170,7 +170,7 @@ func transaction(ctx context.Context, t *testing.T, client datastore.Client) { }() rh := rpcretry.New( - rpcretry.WithLogf(logf), + rpcretry.WithLogger(logf), rpcretry.WithMinBackoffDuration(1), rpcretry.WithRetryLimit(2), ) @@ -377,7 +377,7 @@ func allocateIDs(ctx context.Context, t *testing.T, client datastore.Client) { }() rh := rpcretry.New( - rpcretry.WithLogf(logf), + rpcretry.WithLogger(logf), rpcretry.WithMinBackoffDuration(1), rpcretry.WithRetryLimit(2), ) @@ -468,7 +468,7 @@ func getAll(ctx context.Context, t *testing.T, client datastore.Client) { }() rh := rpcretry.New( - rpcretry.WithLogf(logf), + rpcretry.WithLogger(logf), rpcretry.WithMinBackoffDuration(1), rpcretry.WithRetryLimit(2), ) @@ -613,7 +613,7 @@ func count(ctx context.Context, t *testing.T, client datastore.Client) { }() rh := rpcretry.New( - rpcretry.WithLogf(logf), + rpcretry.WithLogger(logf), rpcretry.WithMinBackoffDuration(1), rpcretry.WithRetryLimit(2), )