Write stats to user table asynchronously

This commit is contained in:
binwiederhier 2022-12-20 21:18:33 -05:00
parent 2f567af80b
commit cc55bec521
6 changed files with 102 additions and 51 deletions

View file

@ -17,6 +17,7 @@ type Manager interface {
CreateToken(user *User) (string, error)
RemoveToken(user *User) error
ChangeSettings(user *User) error
EnqueueUpdateStats(user *User)
// Authorize returns nil if the given user has access to the given topic using the desired
// permission. The user param may be nil to signal an anonymous user.
@ -65,6 +66,7 @@ type User struct {
Grants []Grant
Prefs *UserPrefs
Plan *Plan
Stats *Stats
}
type UserPrefs struct {
@ -102,6 +104,11 @@ type UserNotificationPrefs struct {
DeleteAfter int `json:"delete_after,omitempty"`
}
type Stats struct {
Messages int64
Emails int64
}
// Grant is a struct that represents an access control entry to a topic
type Grant struct {
TopicPattern string // May include wildcard (*)