feat: use queue to feed events, drop if overflowed

This commit is contained in:
Oleh Astappiev 2024-12-08 20:45:44 +01:00
parent b0f0510e8e
commit 02580cce20
No known key found for this signature in database
GPG key ID: 37D7AC22589E9632
7 changed files with 198 additions and 226 deletions

View file

@ -1,5 +1,7 @@
package traefik_umami_feeder
import "context"
type Auth struct {
Username string `json:"username"`
Password string `json:"password"`
@ -9,9 +11,9 @@ type AuthResponse struct {
Token string `json:"token"`
}
func getToken(umamiHost string, umamiUsername string, umamiPassword string) (string, error) {
func getToken(ctx context.Context, umamiHost string, umamiUsername string, umamiPassword string) (string, error) {
var result AuthResponse
err := sendRequestAndParse(umamiHost+"/api/auth/login", Auth{
err := sendRequestAndParse(ctx, umamiHost+"/api/auth/login", Auth{
Username: umamiUsername,
Password: umamiPassword,
}, nil, &result)