[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/02: services: nar-herder: Support ttl and negative-ttl options.
From: |
guix-commits |
Subject: |
01/02: services: nar-herder: Support ttl and negative-ttl options. |
Date: |
Fri, 4 Feb 2022 05:12:04 -0500 (EST) |
cbaines pushed a commit to branch master
in repository guix.
commit 71d2bdfa9fce546e8d8d5103aee4e1096ce65ecf
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Feb 4 10:00:50 2022 +0000
services: nar-herder: Support ttl and negative-ttl options.
* gnu/services/guix.scm (<nar-herder-configuration>): Add ttl and
negative-ttl
fields.
(nar-herder-shepherd-services): Pass the ttl and negative-ttl values to the
service.
* doc/guix.texi (Guix Services): Document this.
---
doc/guix.texi | 14 ++++++++++++++
gnu/services/guix.scm | 18 +++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index aaa7cbb66f..0cf865a672 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -33721,6 +33721,20 @@ Each criteria is specified by a string, then an equals
sign, then
another string. Currently, only one criteria is supported, checking if a
nar is stored on another Nar Herder instance.
+@item @code{ttl} (default: @code{#f})
+Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
+(TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
+days, @code{1m} means 1 month, and so on.
+
+This allows the user's Guix to keep substitute information in cache for
+@var{ttl}.
+
+@item @code{negative-ttl} (default: @code{#f})
+Similarly produce @code{Cache-Control} HTTP headers to advertise the
+time-to-live (TTL) of @emph{negative} lookups---missing store items, for
+which the HTTP 404 code is returned. By default, no negative TTL is
+advertised.
+
@end table
@end deftp
diff --git a/gnu/services/guix.scm b/gnu/services/guix.scm
index 6a5b276b33..dc9bd8ad68 100644
--- a/gnu/services/guix.scm
+++ b/gnu/services/guix.scm
@@ -774,7 +774,12 @@ ca-certificates.crt file in the system profile."
(default "none"))
(storage-nar-removal-criteria
nar-herder-configuration-storage-nar-removal-criteria
- (default '())))
+ (default '()))
+ (ttl nar-herder-configuration-ttl
+ (default #f))
+ (negative-ttl nar-herder-configuration-negative-ttl
+ (default #f)))
+
(define (nar-herder-shepherd-services config)
(match-record config <nar-herder-configuration>
@@ -782,7 +787,8 @@ ca-certificates.crt file in the system profile."
mirror
database database-dump
host port
- storage storage-limit storage-nar-removal-criteria)
+ storage storage-limit storage-nar-removal-criteria
+ ttl negative-ttl)
(unless (or mirror storage)
(error "nar-herder: mirror or storage must be set"))
@@ -817,7 +823,13 @@ ca-certificates.crt file in the system profile."
(match criteria
((k . v) (simple-format #f "~A=~A" k v))
(str str))))
- storage-nar-removal-criteria))
+ storage-nar-removal-criteria)
+ #$@(if ttl
+ (list (string-append "--ttl=" ttl))
+ '())
+ #$@(if negative-ttl
+ (list (string-append "--negative-ttl="
negative-ttl))
+ '()))
#:user #$user
#:group #$group
#:pid-file "/var/run/nar-herder/pid"