chore: move Batcher and Tracker to workspacestats (#13418)

This commit is contained in:
Garrett Delfosse
2024-06-10 15:35:23 -04:00
committed by GitHub
parent c7e7312cb0
commit 5b9a65e5c1
13 changed files with 105 additions and 108 deletions
-6
View File
@@ -7,8 +7,6 @@ import (
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/durationpb"
"github.com/google/uuid"
"cdr.dev/slog"
agentproto "github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/coderd/database"
@@ -16,10 +14,6 @@ import (
"github.com/coder/coder/v2/coderd/workspacestats"
)
type StatsBatcher interface {
Add(now time.Time, agentID uuid.UUID, templateID uuid.UUID, userID uuid.UUID, workspaceID uuid.UUID, st *agentproto.Stats) error
}
type StatsAPI struct {
AgentFn func(context.Context) (database.WorkspaceAgent, error)
Database database.Store
+1 -1
View File
@@ -39,7 +39,7 @@ type statsBatcher struct {
lastStats *agentproto.Stats
}
var _ agentapi.StatsBatcher = &statsBatcher{}
var _ workspacestats.Batcher = &statsBatcher{}
func (b *statsBatcher) Add(now time.Time, agentID uuid.UUID, templateID uuid.UUID, userID uuid.UUID, workspaceID uuid.UUID, st *agentproto.Stats) error {
b.mu.Lock()