services: guix-publish: Add negative-ttl parameter.

* gnu/services/base.scm (guix-publish-configuration): Add 'negative-ttl'
  field.
  (guix-publish-sheperd-service): Process it.
* doc/guix.texi (Base Services)[guix-publish-service-type]: Add item for
  negative-ttl.
This commit is contained in:
Guillaume Le Vaillant 2022-01-20 10:08:04 +01:00
parent 382800fbf0
commit 1aa269d1d7
No known key found for this signature in database
GPG key ID: 6BE8208ADF21FE3F
2 changed files with 18 additions and 4 deletions

View file

@ -69,7 +69,7 @@ Copyright @copyright{} 2019 Ivan Petkov@*
Copyright @copyright{} 2019 Jakob L. Kreuze@* Copyright @copyright{} 2019 Jakob L. Kreuze@*
Copyright @copyright{} 2019 Kyle Andrews@* Copyright @copyright{} 2019 Kyle Andrews@*
Copyright @copyright{} 2019 Alex Griffin@* Copyright @copyright{} 2019 Alex Griffin@*
Copyright @copyright{} 2019, 2020, 2021 Guillaume Le Vaillant@* Copyright @copyright{} 2019, 2020, 2021, 2022 Guillaume Le Vaillant@*
Copyright @copyright{} 2020 Liliana Marie Prikler@* Copyright @copyright{} 2020 Liliana Marie Prikler@*
Copyright @copyright{} 2019, 2020, 2021, 2022 Simon Tournier@* Copyright @copyright{} 2019, 2020, 2021, 2022 Simon Tournier@*
Copyright @copyright{} 2020 Wiktor Żelazny@* Copyright @copyright{} 2020 Wiktor Żelazny@*
@ -16888,6 +16888,11 @@ cache miss. @xref{Invoking guix publish,
When it is an integer, this denotes the @dfn{time-to-live} in seconds When it is an integer, this denotes the @dfn{time-to-live} in seconds
of the published archives. @xref{Invoking guix publish, @option{--ttl}}, of the published archives. @xref{Invoking guix publish, @option{--ttl}},
for more information. for more information.
@item @code{negative-ttl} (default: @code{#f})
When it is an integer, this denotes the @dfn{time-to-live} in
seconds for the negative lookups. @xref{Invoking guix publish,
@option{--negative-ttl}}, for more information.
@end table @end table
@end deftp @end deftp

View file

@ -16,6 +16,7 @@
;;; Copyright © 2021 qblade <qblade@protonmail.com> ;;; Copyright © 2021 qblade <qblade@protonmail.com>
;;; Copyright © 2021 Hui Lu <luhuins@163.com> ;;; Copyright © 2021 Hui Lu <luhuins@163.com>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -196,6 +197,7 @@ (define-module (gnu services base)
guix-publish-configuration-nar-path guix-publish-configuration-nar-path
guix-publish-configuration-cache guix-publish-configuration-cache
guix-publish-configuration-ttl guix-publish-configuration-ttl
guix-publish-configuration-negative-ttl
guix-publish-service-type guix-publish-service-type
gpm-configuration gpm-configuration
@ -1828,7 +1830,9 @@ (define-record-type* <guix-publish-configuration>
(workers guix-publish-configuration-workers ;#f | integer (workers guix-publish-configuration-workers ;#f | integer
(default #f)) (default #f))
(ttl guix-publish-configuration-ttl ;#f | integer (ttl guix-publish-configuration-ttl ;#f | integer
(default #f))) (default #f))
(negative-ttl guix-publish-configuration-negative-ttl ;#f | integer
(default #f)))
(define-deprecated (guix-publish-configuration-compression-level config) (define-deprecated (guix-publish-configuration-compression-level config)
"Return a compression level, the old way." "Return a compression level, the old way."
@ -1863,8 +1867,8 @@ (define (config->compression-options config)
lst)))) lst))))
(match-record config <guix-publish-configuration> (match-record config <guix-publish-configuration>
(guix port host nar-path cache workers ttl cache-bypass-threshold (guix port host nar-path cache workers ttl negative-ttl
advertise?) cache-bypass-threshold advertise?)
(list (shepherd-service (list (shepherd-service
(provision '(guix-publish)) (provision '(guix-publish))
(requirement `(user-processes (requirement `(user-processes
@ -1890,6 +1894,11 @@ (define (config->compression-options config)
#$(number->string ttl) #$(number->string ttl)
"s")) "s"))
#~()) #~())
#$@(if negative-ttl
#~((string-append "--negative-ttl="
#$(number->string negative-ttl)
"s"))
#~())
#$@(if cache #$@(if cache
#~((string-append "--cache=" #$cache) #~((string-append "--cache=" #$cache)
#$(string-append #$(string-append