-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 822 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"log"
"sync"
"time"
client "github.com/influxdata/influxdb1-client/v2"
"github.com/vitwit/celo-alert-bot/config"
"github.com/vitwit/celo-alert-bot/server"
)
func main() {
cfg, err := config.ReadFromFile()
if err != nil {
log.Fatal(err)
}
c, err := client.NewHTTPClient(client.HTTPConfig{
Addr: fmt.Sprintf("http://localhost:%s", cfg.InfluxDB.Port),
Username: cfg.InfluxDB.Username,
Password: cfg.InfluxDB.Password,
})
if err != nil {
log.Fatal(err)
}
defer c.Close()
var wg sync.WaitGroup
wg.Add(1)
// Calling go routine to send alerts of new proposals
go func() {
for {
if err := server.NewProposalAlert(cfg, c); err != nil {
fmt.Println("Error while sending new proposal alert", err)
}
time.Sleep(3 * time.Second)
}
}()
wg.Wait()
}