Skip to content

chore: move Batcher and Tracker to workspacestats #13418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 10, 2024
Merged

Conversation

f0ssel
Copy link
Contributor

@f0ssel f0ssel commented May 30, 2024

This moves the batchstats.Batcher and workspaceusage.Tracker into the workspacestats package to keep all updates to last_used_at inside the same package. There are no functional changes in this PR.

Comment on lines 27 to 29
type StatsBatcher interface {
Add(now time.Time, agentID uuid.UUID, templateID uuid.UUID, userID uuid.UUID, workspaceID uuid.UUID, st *agentproto.Stats) error
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this interface and the batcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a test implementation at https://github.com/coder/coder/blob/f0ssel/move-batchers/coderd/agentapi/stats_test.go#L30. That being said, there's a duplicate definition of this interface at https://github.com/coder/coder/blob/f0ssel/move-batchers/coderd/agentapi/stats.go#L19 that can be removed.

Comment on lines +871 to +874
batcher, closeBatcher, err := workspacestats.NewBatcher(ctx,
workspacestats.BatcherWithLogger(options.Logger.Named("batchstats")),
workspacestats.BatcherWithStore(options.Database),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly married to the functional opts here if you want to use a more conventional opts struct instead or just straight-up function args.

@github-actions github-actions bot added the stale This issue is like stale bread. label Jun 8, 2024
@f0ssel f0ssel force-pushed the f0ssel/move-batchers branch from e2b56ec to 9295149 Compare June 10, 2024 18:49
@f0ssel f0ssel removed the stale This issue is like stale bread. label Jun 10, 2024
@f0ssel f0ssel merged commit 5b9a65e into main Jun 10, 2024
30 checks passed
@f0ssel f0ssel deleted the f0ssel/move-batchers branch June 10, 2024 19:35
@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants