Use map instead of separate vars
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2019-03-24 14:02:23 +01:00
parent 312ef8b873
commit 0f9e3043ef
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -51,15 +51,11 @@ type Feed struct {
}
var (
subscribeRuns *expvar.Int
resubscriptions *expvar.Int
resubscribeErrors *expvar.Int
varWebsub *expvar.Map
)
func init() {
subscribeRuns = expvar.NewInt("subscribe.runs")
resubscriptions = expvar.NewInt("subscribe.calls")
resubscribeErrors = expvar.NewInt("subscribe.errors")
varWebsub = expvar.NewMap("websub")
}
func (h *hubIncomingBackend) GetSecret(id int64) string {
@ -244,7 +240,7 @@ func (h *hubIncomingBackend) run() error {
select {
case <-ticker.C:
log.Println("Getting feeds for WebSub")
subscribeRuns.Add(1)
varWebsub.Add("runs", 1)
feeds, err := h.Feeds()
if err != nil {
@ -257,11 +253,11 @@ func (h *hubIncomingBackend) run() error {
feed.Callback = fmt.Sprintf("%s/incoming/%d", h.baseURL, feed.ID)
}
log.Printf("Send resubscribe for %q on %q with callback %q\n", feed.URL, feed.Hub, feed.Callback)
resubscriptions.Add(1)
varWebsub.Add("resubscribe", 1)
err := h.Subscribe(&feed)
if err != nil {
log.Printf("Error while subscribing: %s", err)
resubscribeErrors.Add(1)
varWebsub.Add("errors", 1)
}
}
}