refactor(metrics): drop the user count listener

The user count is now counted on demand, so the increment-on-create
listener is no longer needed.
This commit is contained in:
kolaente 2026-05-30 15:03:13 +02:00 committed by kolaente
parent 051f734f3d
commit 06000b7a03
2 changed files with 4 additions and 28 deletions

View File

@ -16,30 +16,7 @@
package user
import (
"code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/metrics"
"code.vikunja.io/api/pkg/modules/keyvalue"
"github.com/ThreeDotsLabs/watermill/message"
)
func RegisterListeners() {
events.RegisterListener((&CreatedEvent{}).Name(), &IncreaseUserCounter{})
}
///////
// User Events
// IncreaseUserCounter represents a listener
type IncreaseUserCounter struct {
}
// Name defines the name for the IncreaseUserCounter listener
func (s *IncreaseUserCounter) Name() string {
return "increase.user.counter"
}
// Handle is executed when the event IncreaseUserCounter listens on is fired
func (s *IncreaseUserCounter) Handle(_ *message.Message) (err error) {
return keyvalue.IncrBy(metrics.UserCountKey, 1)
}
// RegisterListeners registers all event listeners for the user package.
// The user count metric is now counted on demand (see pkg/metrics), so there are
// currently no listeners to register. This hook is kept for future user events.
func RegisterListeners() {}

View File

@ -159,7 +159,6 @@ func init() {
"ErrUsernameReserved": reflect.ValueOf((*user.ErrUsernameReserved)(nil)),
"ErrWrongUsernameOrPassword": reflect.ValueOf((*user.ErrWrongUsernameOrPassword)(nil)),
"FailedLoginAttemptNotification": reflect.ValueOf((*user.FailedLoginAttemptNotification)(nil)),
"IncreaseUserCounter": reflect.ValueOf((*user.IncreaseUserCounter)(nil)),
"InvalidTOTPNotification": reflect.ValueOf((*user.InvalidTOTPNotification)(nil)),
"Login": reflect.ValueOf((*user.Login)(nil)),
"PasswordAccountLockedAfterInvalidTOTPNotification": reflect.ValueOf((*user.PasswordAccountLockedAfterInvalidTOTPNotification)(nil)),