jiralert
jiralert copied to clipboard
feat: reuse jira clients to reuse connections
Keep reusable clients by username.
@bwplotka I made the changes you suggested.
I an error assignment to entry in nil map
./jiralert -listen-address 0.0.0.0:9099 -hash-jira-label
level=info ts=2023-10-18T12:35:04.436816899Z caller=main.go:65 msg="starting JIRAlert" version="<local build>"
level=info ts=2023-10-18T12:35:04.436879529Z caller=config.go:62 msg="loading configuration" path=config/jiralert.yml
level=info ts=2023-10-18T12:35:04.437967933Z caller=main.go:135 msg=listening address=0.0.0.0:9099
2023/10/18 14:35:07 http: panic serving 192.168.48.1:52577: assignment to entry in nil map
goroutine 37 [running]:
net/http.(*conn).serve.func1()
/usr/lib/go-1.20/src/net/http/server.go:1854 +0xbf
panic({0x972e60, 0xada4c0})
/usr/lib/go-1.20/src/runtime/panic.go:890 +0x263
github.com/prometheus-community/jiralert/pkg/clientset.(*ClientSet).newJira(0xc0002a4e40, 0xc000254500)
/home/holge/git/jiralert/pkg/clientset/clientset.go:68 +0x35d
github.com/prometheus-community/jiralert/pkg/clientset.(*ClientSet).GetOrCreateJira(0xc000210870?, 0xc0002a9180?)
/home/holge/git/jiralert/pkg/clientset/clientset.go:76 +0x19
main.main.func1({0xadeb60, 0xc000216460}, 0xc000255200)
/home/holge/git/jiralert/cmd/jiralert/main.go:105 +0x497
net/http.HandlerFunc.ServeHTTP(0xc000216460?, {0xadeb60?, 0xc000216460?}, 0xa10a73?)
/usr/lib/go-1.20/src/net/http/server.go:2122 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0xadeb60, 0xc000216460}, 0xc000255200)
/usr/lib/go-1.20/src/net/http/server.go:2500 +0x149
net/http.serverHandler.ServeHTTP({0xadd598?}, {0xadeb60, 0xc000216460}, 0xc000255200)
/usr/lib/go-1.20/src/net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc00024a630, {0xadf0f0, 0xc0002adc80})
/usr/lib/go-1.20/src/net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
/usr/lib/go-1.20/src/net/http/server.go:3089 +0x5ed
It really was only a missing map initialization
c.jira = map[string]*jira.Client{}
It really was only a missing map initialization
c.jira = map[string]*jira.Client{}
Updated, thanks.