diff --git a/clients/alert_manager/client.go b/clients/alert_manager/client.go index 909876f..9164a09 100644 --- a/clients/alert_manager/client.go +++ b/clients/alert_manager/client.go @@ -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, } } diff --git a/clients/alert_manager/client_test.go b/clients/alert_manager/client_test.go index 507d6a3..2690472 100644 --- a/clients/alert_manager/client_test.go +++ b/clients/alert_manager/client_test.go @@ -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{ {