rss email digests over ssh because you're a cool kid herald.dunkirk.sh
go rss rss-reader ssh charm
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: extract constants

dunkirk.sh 791afd16 81f76366

verified
+16 -7
+4 -3
scheduler/scheduler.go
··· 14 14 15 15 const ( 16 16 // Email rate limiting 17 - emailsPerMinutePerUser = 1 18 - emailRateBurst = 1 17 + emailsPerMinutePerUser = 1 18 + emailRateBurst = 1 19 + emailsPerSecondPerUser = emailsPerMinutePerUser / 60.0 19 20 20 21 // Cleanup intervals 21 22 cleanupInterval = 24 * time.Hour ··· 42 43 logger: logger, 43 44 interval: interval, 44 45 originURL: originURL, 45 - rateLimiter: ratelimit.New(1.0/60.0, emailRateBurst), 46 + rateLimiter: ratelimit.New(emailsPerSecondPerUser, emailRateBurst), 46 47 } 47 48 } 48 49
+5 -3
web/handlers.go
··· 15 15 const ( 16 16 maxFeedItems = 100 17 17 shortFingerprintLen = 8 18 + recentItemsLimit = 50 19 + feedCacheMaxAge = 300 // 5 minutes 18 20 ) 19 21 20 22 func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { ··· 275 277 276 278 // Add caching headers 277 279 w.Header().Set("Content-Type", "application/rss+xml; charset=utf-8") 278 - w.Header().Set("Cache-Control", "public, max-age=300") 280 + w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", feedCacheMaxAge)) 279 281 if cfg.LastRun.Valid { 280 282 etag := fmt.Sprintf(`"%s-%d"`, fingerprint[:shortFingerprintLen], cfg.LastRun.Time.Unix()) 281 283 w.Header().Set("ETag", etag) ··· 356 358 } 357 359 358 360 for _, feed := range feeds { 359 - seenItems, err := s.store.GetSeenItems(ctx, feed.ID, 50) 361 + seenItems, err := s.store.GetSeenItems(ctx, feed.ID, recentItemsLimit) 360 362 if err != nil { 361 363 continue 362 364 } ··· 402 404 403 405 // Add caching headers 404 406 w.Header().Set("Content-Type", "application/feed+json; charset=utf-8") 405 - w.Header().Set("Cache-Control", "public, max-age=300") 407 + w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", feedCacheMaxAge)) 406 408 if cfg.LastRun.Valid { 407 409 etag := fmt.Sprintf(`"%s-%d"`, fingerprint[:shortFingerprintLen], cfg.LastRun.Time.Unix()) 408 410 w.Header().Set("ETag", etag)
+7 -1
web/server.go
··· 17 17 //go:embed templates/* 18 18 var templatesFS embed.FS 19 19 20 + const ( 21 + // HTTP rate limiting 22 + httpRequestsPerSecond = 10 23 + httpRateLimiterBurst = 20 24 + ) 25 + 20 26 type Server struct { 21 27 store *store.DB 22 28 addr string ··· 39 45 logger: logger, 40 46 tmpl: tmpl, 41 47 commitHash: commitHash, 42 - rateLimiter: ratelimit.New(10, 20), // 10 req/sec, burst of 20 48 + rateLimiter: ratelimit.New(httpRequestsPerSecond, httpRateLimiterBurst), 43 49 metrics: NewMetrics(), 44 50 } 45 51 }