added alert manager cfg to client alert manager
This commit is contained in:
parent
bc69f006f7
commit
2454377ad2
@ -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{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user