func init() { hC := checks.NewHttpCaller(10) //key is the endpoint alias from the config endpointSpecificChecks = map[string]EndpointSpecificCheck{ "content": ContentCheck{hC}, "S3": S3Check{hC}, "enrichedContent": ContentCheck{hC}, "lists": ContentCheck{hC}, "notifications": NotificationsCheck{hC, subscribedFeeds, "notifications"}, "notifications-push": NotificationsCheck{hC, subscribedFeeds, "notifications-push"}, "list-notifications": NotificationsCheck{hC, subscribedFeeds, "list-notifications"}, "list-notifications-push": NotificationsCheck{hC, subscribedFeeds, "list-notifications-push"}, } }
func (f *NotificationsPushFeed) Start() { infoLogger.Printf("starting notifications-push feed from %v", f.baseUrl) f.stopFeedLock.Lock() defer f.stopFeedLock.Unlock() f.stopFeed = false go func() { if f.httpCaller == nil { f.httpCaller = checks.NewHttpCaller(0) } for f.consumeFeed() { time.Sleep(500 * time.Millisecond) infoLogger.Println("Disconnected from Push feed! Attempting to reconnect.") } }() }
func (f *NotificationsPullFeed) Start() { if f.httpCaller == nil { f.httpCaller = checks.NewHttpCaller(10) } f.ticker = time.NewTicker(time.Duration(f.interval) * time.Second) f.poller = make(chan struct{}) go func() { for { select { case <-f.ticker.C: go func() { f.pollNotificationsFeed() f.purgeObsoleteNotifications() }() case <-f.poller: f.ticker.Stop() return } } }() }