added alert manager cfg to client alert manager

This commit is contained in:
Pasha 2024-12-31 12:05:36 +03:00
parent bc69f006f7
commit 2454377ad2
2 changed files with 7 additions and 3 deletions

@ -15,15 +15,19 @@ type Alert struct {
GeneratorURL string `json:"generatorURL"`
}
type AlertManagerCfg struct {
AlertManagerHttpURL string `env:"ALERT_MANAGER_HTTP_URL"`
}
type Client struct {
baseURL string
httpClient *fiber.Client
}
func NewClient(baseURL string) *Client {
func NewClient(cfg AlertManagerCfg) *Client {
httpClient := fiber.AcquireClient()
return &Client{
baseURL: baseURL,
baseURL: cfg.AlertManagerHttpURL,
httpClient: httpClient,
}
}

@ -8,7 +8,7 @@ import (
)
func TestClient_SendAlerts(t *testing.T) {
client := NewClient("http://localhost:9093")
client := NewClient(AlertManagerCfg{AlertManagerHttpURL: "http://localhost:9093"})
for i := 0; i < 50; i++ {
err := client.SendAlerts([]Alert{
{