Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (re RetriableError) Error() string {
}

// RetriableErrorf wraps a formatted string into a RetriableError.
func RetriableErrorf(format string, a ...interface{}) error {
func RetriableErrorf(format string, a ...any) error {
return RetriableError(fmt.Sprintf(format, a...))
}

Expand Down
2 changes: 1 addition & 1 deletion integration/storagetest/logtests.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func RunLogStorageTests(t *testing.T, storageFactory LogStorageFactory) {
}
}

func logTestFunctions(t *testing.T, x interface{}) map[string]LogStorageTest {
func logTestFunctions(t *testing.T, x any) map[string]LogStorageTest {
tests := make(map[string]LogStorageTest)
xv := reflect.ValueOf(x)
for _, name := range testFunctions(x) {
Expand Down
2 changes: 1 addition & 1 deletion integration/storagetest/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"
)

func testFunctions(x interface{}) []string {
func testFunctions(x any) []string {
const prefix = "Test"
xt := reflect.TypeOf(x)
tests := []string{}
Expand Down
2 changes: 1 addition & 1 deletion log/operation_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type logOpInfoMatcher struct {
BatchSize int
}

func (l logOpInfoMatcher) Matches(x interface{}) bool {
func (l logOpInfoMatcher) Matches(x any) bool {
o, ok := x.(*OperationInfo)
if !ok {
return false
Expand Down
4 changes: 2 additions & 2 deletions log/sequencer_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func TestSequencerManagerSingleLogOneLeaf(t *testing.T) {

// cmpMatcher is a custom gomock.Matcher that uses cmp.Equal combined with a
// cmp.Comparer that knows how to properly compare proto.Message types.
type cmpMatcher struct{ want interface{} }
type cmpMatcher struct{ want any }

func (m cmpMatcher) Matches(got interface{}) bool {
func (m cmpMatcher) Matches(got any) bool {
return cmp.Equal(got, m.want, cmp.Comparer(proto.Equal))
}

Expand Down
2 changes: 1 addition & 1 deletion monitoring/rpc_stats_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (r *RPCStatsInterceptor) recordFailureLatency(labels []string, startTime ti
// Interceptor returns a UnaryServerInterceptor that can be registered with an RPC server and
// will record request counts / errors and latencies for that servers handlers
func (r *RPCStatsInterceptor) Interceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
return func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
labels := []string{info.FullMethod}

// This interceptor wraps the request handler so we should track the
Expand Down
6 changes: 3 additions & 3 deletions monitoring/rpc_stats_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ var fakeTime = time.Date(2016, 10, 3, 12, 38, 27, 36, time.UTC)
type recordingUnaryHandler struct {
// ctx and req are recorded on invocation
ctx context.Context
req interface{}
req any
// rsp and err are returned on invocation
rsp interface{}
rsp any
err error
}

func (r recordingUnaryHandler) handler() grpc.UnaryHandler {
return func(ctx context.Context, req interface{}) (interface{}, error) {
return func(ctx context.Context, req any) (any, error) {
r.ctx = ctx
r.req = req
return r.rsp, r.err
Expand Down
6 changes: 3 additions & 3 deletions quota/etcd/quotaapi/quota_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestServer_CreateConfig(t *testing.T) {
}

ctx := context.Background()
rpc := func(ctx context.Context, req interface{}) (*quotapb.Config, error) {
rpc := func(ctx context.Context, req any) (*quotapb.Config, error) {
return quotaClient.CreateConfig(ctx, req.(*quotapb.CreateConfigRequest))
}
for _, test := range tests {
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestServer_UpdateConfig(t *testing.T) {
}

ctx := context.Background()
rpc := func(ctx context.Context, req interface{}) (*quotapb.Config, error) {
rpc := func(ctx context.Context, req any) (*quotapb.Config, error) {
return quotaClient.UpdateConfig(ctx, req.(*quotapb.UpdateConfigRequest))
}
for _, test := range tests {
Expand Down Expand Up @@ -462,7 +462,7 @@ type upsertRequest interface {
GetName() string
}

type upsertRPC func(ctx context.Context, req interface{}) (*quotapb.Config, error)
type upsertRPC func(ctx context.Context, req any) (*quotapb.Config, error)

// runUpsertTest runs either CreateConfig or UpdateConfig tests, depending on the supplied rpc.
// Storage is reset() before the test is executed.
Expand Down
10 changes: 5 additions & 5 deletions quota/redis/redistb/redistb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
// implementations (e.g. regular Redis, Redis Cluster, sharded, etc.)
type RedisClient interface {
// Required to load and execute scripts
Eval(script string, keys []string, args ...interface{}) *redis.Cmd
EvalSha(sha1 string, keys []string, args ...interface{}) *redis.Cmd
Eval(script string, keys []string, args ...any) *redis.Cmd
EvalSha(sha1 string, keys []string, args ...any) *redis.Cmd
ScriptExists(hashes ...string) *redis.BoolSliceCmd
ScriptLoad(script string) *redis.StringCmd
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func (tb *TokenBucket) Call(
now, nowUs = timeToRedisPair(tb.timeSource.Now())
}

args := []interface{}{
args := []any{
replenishRate,
capacity,
numTokens,
Expand All @@ -124,9 +124,9 @@ func (tb *TokenBucket) Call(
return false, 0, err
}

returnVals, ok := result.([]interface{})
returnVals, ok := result.([]any)
if !ok {
return false, 0, fmt.Errorf("redistb: invalid return type %T (expected []interface{})", result)
return false, 0, fmt.Errorf("redistb: invalid return type %T (expected []any)", result)
}

// The script returns:
Expand Down
4 changes: 2 additions & 2 deletions quota/redis/redistb/redistb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,9 @@ func deserializeRedisResults(t *testing.T, resp *redis.Cmd) (bool, int64, int64,
}

// Deserialize results
returnVals, ok := results.([]interface{})
returnVals, ok := results.([]any)
if !ok {
t.Fatalf("invalid return type %T (expected []interface{})", results)
t.Fatalf("invalid return type %T (expected []any)", results)
}

var allowed bool
Expand Down
18 changes: 9 additions & 9 deletions server/interceptor/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ type RequestProcessor interface {
// Before implements all interceptor logic that happens before the handler is called.
// It returns a (potentially) modified context that's passed forward to the handler (and After),
// plus an error, in case the request should be interrupted before the handler is invoked.
Before(ctx context.Context, req interface{}, method string) (context.Context, error)
Before(ctx context.Context, req any, method string) (context.Context, error)

// After implements all interceptor logic that happens after the handler is invoked.
// Before must be invoked prior to After and the same RequestProcessor instance must to be used
// to process a given request.
After(ctx context.Context, resp interface{}, method string, handlerErr error)
After(ctx context.Context, resp any, method string, handlerErr error)
}

// TrillianInterceptor checks that:
Expand Down Expand Up @@ -124,7 +124,7 @@ func incRequestDeniedCounter(reason string, treeID int64, quotaUser string) {
}

// UnaryInterceptor executes the TrillianInterceptor logic for unary RPCs.
func (i *TrillianInterceptor) UnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
func (i *TrillianInterceptor) UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
// Implement UnaryInterceptor using a RequestProcessor, so we
// 1. exercise it
// 2. make it easier to port this logic to non-gRPC implementations.
Expand All @@ -150,7 +150,7 @@ type trillianProcessor struct {
info *rpcInfo
}

func (tp *trillianProcessor) Before(ctx context.Context, req interface{}, method string) (context.Context, error) {
func (tp *trillianProcessor) Before(ctx context.Context, req any, method string) (context.Context, error) {
// Skip if the interceptor is not enabled for this service.
if !enabledServices[serviceName(method)] {
return ctx, nil
Expand Down Expand Up @@ -203,7 +203,7 @@ func (tp *trillianProcessor) Before(ctx context.Context, req interface{}, method
return ctx, nil
}

func (tp *trillianProcessor) After(ctx context.Context, resp interface{}, method string, handlerErr error) {
func (tp *trillianProcessor) After(ctx context.Context, resp any, method string, handlerErr error) {
if !enabledServices[serviceName(method)] {
return
}
Expand Down Expand Up @@ -319,7 +319,7 @@ type chargable interface {
}

// chargedUsers returns user identifiers for any chargable user quotas.
func chargedUsers(req interface{}) []string {
func chargedUsers(req any) []string {
c, ok := req.(chargable)
if !ok {
return nil
Expand All @@ -332,7 +332,7 @@ func chargedUsers(req interface{}) []string {
return chargeTo.User
}

func newRPCInfoForRequest(req interface{}) (*rpcInfo, error) {
func newRPCInfoForRequest(req any) (*rpcInfo, error) {
// Set "safe" defaults: enable all interception and assume requests are readonly.
info := &rpcInfo{
getTree: true,
Expand Down Expand Up @@ -413,7 +413,7 @@ func newRPCInfoForRequest(req interface{}) (*rpcInfo, error) {
return info, nil
}

func newRPCInfo(req interface{}) (*rpcInfo, error) {
func newRPCInfo(req any) (*rpcInfo, error) {
info, err := newRPCInfoForRequest(req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -467,7 +467,7 @@ type treeRequest interface {
}

// ErrorWrapper is a grpc.UnaryServerInterceptor that wraps the errors emitted by the underlying handler.
func ErrorWrapper(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
func ErrorWrapper(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
ctx, spanEnd := spanFor(ctx, "ErrorWrapper")
defer spanEnd()
rsp, err := handler(ctx, req)
Expand Down
24 changes: 12 additions & 12 deletions server/interceptor/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestTrillianInterceptor_TreeInterception(t *testing.T) {
tests := []struct {
desc string
method string
req interface{}
req any
handlerErr error
wantErr bool
wantTree *trillian.Tree
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestTrillianInterceptor_QuotaInterception(t *testing.T) {
desc string
dryRun bool
method string
req interface{}
req any
specs []quota.Spec
getTokensErr error
wantCode codes.Code
Expand Down Expand Up @@ -371,7 +371,7 @@ func TestTrillianInterceptor_QuotaInterception_ReturnsTokens(t *testing.T) {
tests := []struct {
desc string
method string
req, resp interface{}
req, resp any
specs []quota.Spec
handlerErr error
wantGetTokens, wantPutTokens int
Expand Down Expand Up @@ -485,7 +485,7 @@ func TestTrillianInterceptor_QuotaInterception_ReturnsTokens(t *testing.T) {
func TestTrillianInterceptor_NotIntercepted(t *testing.T) {
tests := []struct {
method string
req interface{}
req any
}{
// Admin
{method: "/trillian.TrillianAdmin/CreateTree", req: &trillian.CreateTreeRequest{}},
Expand Down Expand Up @@ -524,7 +524,7 @@ func TestTrillianInterceptor_BeforeAfter(t *testing.T) {

tests := []struct {
desc string
req, resp interface{}
req, resp any
handlerErr error
wantBeforeErr bool
}{
Expand Down Expand Up @@ -690,7 +690,7 @@ func TestErrorWrapper(t *testing.T) {
badLlamaErr := status.Errorf(codes.InvalidArgument, "Bad Llama")
tests := []struct {
desc string
resp interface{}
resp any
err, wantErr error
}{
{
Expand Down Expand Up @@ -724,14 +724,14 @@ func equalError(x, y error) bool {

type fakeHandler struct {
called bool
resp interface{}
resp any
err error
// Attributes recorded by run calls
ctx context.Context
req interface{}
req any
}

func (f *fakeHandler) run(ctx context.Context, req interface{}) (interface{}, error) {
func (f *fakeHandler) run(ctx context.Context, req any) (any, error) {
if f.called {
panic("handler already called; either create a new handler or set called to false before reusing")
}
Expand All @@ -742,13 +742,13 @@ func (f *fakeHandler) run(ctx context.Context, req interface{}) (interface{}, er
}

type fakeInterceptor struct {
key interface{}
val interface{}
key any
val any
called bool
err error
}

func (f *fakeInterceptor) run(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
func (f *fakeInterceptor) run(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
if f.called {
panic("interceptor already called; either create a new interceptor or set called to false before reusing")
}
Expand Down
4 changes: 2 additions & 2 deletions server/log_rpc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import (

// cmpMatcher is a custom gomock.Matcher that uses cmp.Equal combined with a
// cmp.Comparer that knows how to properly compare proto.Message types.
type cmpMatcher struct{ want interface{} }
type cmpMatcher struct{ want any }

func (m cmpMatcher) Matches(got interface{}) bool {
func (m cmpMatcher) Matches(got any) bool {
return cmp.Equal(got, m.want, cmp.Comparer(proto.Equal))
}

Expand Down
4 changes: 2 additions & 2 deletions storage/cloudspanner/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (t *adminTX) CreateTree(ctx context.Context, tree *trillian.Tree) (*trillia
"TreeInfo",
"Deleted",
},
[]interface{}{
[]any{
info.TreeId,
int64(info.TreeState),
int64(info.TreeType),
Expand Down Expand Up @@ -436,7 +436,7 @@ func (t *adminTX) updateTreeInfo(ctx context.Context, info *spannerpb.TreeInfo)
"Deleted",
"DeleteTimeMillis",
},
[]interface{}{
[]any{
info.TreeId,
int64(info.TreeState),
int64(info.TreeType),
Expand Down
2 changes: 1 addition & 1 deletion storage/cloudspanner/log_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func (tx *logTX) StoreSignedLogRoot(ctx context.Context, root *trillian.SignedLo
"TreeRevision",
"TreeMetadata",
},
[]interface{}{
[]any{
int64(tx.treeID),
int64(logRoot.TimestampNanos),
int64(logRoot.TreeSize),
Expand Down
2 changes: 1 addition & 1 deletion storage/cloudspanner/tree_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (t *treeTX) storeSubtrees(ctx context.Context, sts []*storagepb.SubtreeProt
m := spanner.Insert(
subtreeTbl,
[]string{colTreeID, colSubtreeID, colRevision, colSubtree},
[]interface{}{t.treeID, st.Prefix, t._writeRev, stBytes},
[]any{t.treeID, st.Prefix, t._writeRev, stBytes},
)
if err := stx.BufferWrite([]*spanner.Mutation{m}); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion storage/crdb/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestMain(m *testing.M) {
status := m.Run()

// Clean up databases
testDBs.Range(func(key, value interface{}) bool {
testDBs.Range(func(key, value any) bool {
testName := key.(string)
klog.Infof("Cleaning up database for test %s", testName)

Expand Down
6 changes: 3 additions & 3 deletions storage/crdb/log_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (t *logTreeTX) QueueLeaves(ctx context.Context, leaves []*trillian.LogLeaf,
}

// Create the work queue entry
args := []interface{}{
args := []any{
t.treeID,
leaf.LeafIdentityHash,
leaf.MerkleLeafHash,
Expand Down Expand Up @@ -661,7 +661,7 @@ func (t *logTreeTX) getLeavesByRangeInternal(ctx context.Context, start, count i
}
// TODO(pavelkalinnikov): Further clip `count` to a safe upper bound like 64k.

args := []interface{}{start, start + count, t.treeID}
args := []any{start, start + count, t.treeID}
rows, err := t.tx.QueryContext(ctx, selectLeavesByRangeSQL, args...)
if err != nil {
klog.Warningf("Failed to get leaves by range: %s", err)
Expand Down Expand Up @@ -808,7 +808,7 @@ func (t *logTreeTX) getLeavesByHashInternal(ctx context.Context, leafHashes [][]
}
}()

var args []interface{}
var args []any
for _, hash := range leafHashes {
args = append(args, []byte(hash))
}
Expand Down
Loading