subdocchecker.go 602 B

1234567891011121314151617181920212223242526
  1. package subscriptionmanager
  2. import "time"
  3. func (s *SubscriptionManagerImpl) checkupSubscription(subscriptionName string) error {
  4. var trackedSub *trackedSubscription
  5. if trackedSubFound, found := s.trackedSubscriptions[subscriptionName]; !found {
  6. return newError("not found")
  7. } else {
  8. trackedSub = trackedSubFound
  9. }
  10. shouldUpdate := false
  11. if trackedSub.currentDocumentExpireTime.Before(time.Now()) {
  12. shouldUpdate = true
  13. }
  14. if shouldUpdate {
  15. if err := s.updateSubscription(subscriptionName); err != nil {
  16. return newError("failed to update subscription: ", err)
  17. }
  18. }
  19. return nil
  20. }