Skip to content

Commit

Permalink
srvtopo: Additional cleanup
Browse files Browse the repository at this point in the history
We don't need to store this in the resilient server, we can just pass it
down to the watchers instead.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Feb 23, 2024
1 parent 7bf5860 commit b079331
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions go/vt/srvtopo/resilient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const (
// - return the last known value of the data if there is an error
type ResilientServer struct {
topoServer *topo.Server
counts *stats.CountersWithSingleLabel

*SrvKeyspaceWatcher
*SrvVSchemaWatcher
Expand All @@ -86,7 +85,6 @@ func NewResilientServer(ctx context.Context, base *topo.Server, counts *stats.Co

return &ResilientServer{
topoServer: base,
counts: counts,
SrvKeyspaceWatcher: NewSrvKeyspaceWatcher(ctx, base, counts, srvTopoCacheRefresh, srvTopoCacheTTL),
SrvVSchemaWatcher: NewSrvVSchemaWatcher(ctx, base, counts, srvTopoCacheRefresh, srvTopoCacheTTL),
SrvKeyspaceNamesQuery: NewSrvKeyspaceNamesQuery(base, counts, srvTopoCacheRefresh, srvTopoCacheTTL),
Expand Down
6 changes: 3 additions & 3 deletions go/vt/srvtopo/resilient_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestGetSrvKeyspace(t *testing.T) {
// Now simulate a topo service error and see that the last value is
// cached for at least half of the expected ttl.
errorTestStart := time.Now()
errorReqsBefore := rs.counts.Counts()[errorCategory]
errorReqsBefore := counts.Counts()[errorCategory]
forceErr := topo.NewError(topo.Timeout, "test topo error")
factory.SetError(forceErr)

Expand Down Expand Up @@ -273,7 +273,7 @@ func TestGetSrvKeyspace(t *testing.T) {

// Check that the expected number of errors were counted during the
// interval
errorReqs := rs.counts.Counts()[errorCategory]
errorReqs := counts.Counts()[errorCategory]
expectedErrors := int64(time.Since(errorTestStart) / srvTopoCacheRefresh)
if errorReqs-errorReqsBefore > expectedErrors {
t.Errorf("expected <= %v error requests got %d", expectedErrors, errorReqs-errorReqsBefore)
Expand Down Expand Up @@ -646,7 +646,7 @@ func TestGetSrvKeyspaceNames(t *testing.T) {
t.Errorf("GetSrvKeyspaceNames got %v want %v", names, wantNames)
}

errorReqs, ok := rs.counts.Counts()[errorCategory]
errorReqs, ok := counts.Counts()[errorCategory]
if !ok || errorReqs == 0 {
t.Errorf("expected non-zero error requests got %v", errorReqs)
}
Expand Down

0 comments on commit b079331

Please sign in to comment.