mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
services: Modernize redis service.
* gnu/services/databases.scm (redis-configuration): Rewrite using `define-configuration'. (redis-shepherd-service): Honor it. * doc/guix.texi (Database Services) <redis>: Regenerate documentation. Change-Id: I5b99822ca3d8d23fb5133497d00eada0336d0c65 Signed-off-by: Ludovic Courtès <ludo@gnu.org> Merges: #2158
This commit is contained in:
committed by
Ludovic Courtès
parent
b00a27c427
commit
4b25873c12
@@ -28343,30 +28343,47 @@ Additional command line options to pass to @code{memcached}.
|
|||||||
|
|
||||||
@subsubheading Redis
|
@subsubheading Redis
|
||||||
|
|
||||||
|
@uref{https://redis.io/, Redis} is an in-memory data store used
|
||||||
|
by millions of developers as a cache, vector database, document
|
||||||
|
database, streaming engine, and message broker. Redis has built-in
|
||||||
|
replication and different levels of on-disk persistence. It supports
|
||||||
|
complex data types (for example, strings, hashes, lists, sets, sorted
|
||||||
|
sets, and JSON), with atomic operations defined on those data types.
|
||||||
|
|
||||||
@defvar redis-service-type
|
@defvar redis-service-type
|
||||||
This is the service type for the @uref{https://redis.io/, Redis}
|
Type of the service that runs @command{redis}, an in-memory data store.
|
||||||
key/value store, whose value is a @code{redis-configuration} object.
|
The value for this service is a @code{<redis-configuration>} object.
|
||||||
@end defvar
|
@end defvar
|
||||||
|
|
||||||
|
@c %start of fragment
|
||||||
|
|
||||||
@deftp {Data Type} redis-configuration
|
@deftp {Data Type} redis-configuration
|
||||||
Data type representing the configuration of redis.
|
Available @code{redis-configuration} fields are:
|
||||||
|
|
||||||
@table @asis
|
@table @asis
|
||||||
@item @code{redis} (default: @code{redis})
|
@item @code{redis} (default: @code{redis}) (type: package)
|
||||||
The Redis package to use.
|
The Redis package to use.
|
||||||
|
|
||||||
@item @code{bind} (default: @code{"127.0.0.1"})
|
@item @code{bind} (default: @code{"127.0.0.1"}) (type: string)
|
||||||
Network interface on which to listen.
|
Network interface on which to listen.
|
||||||
|
|
||||||
@item @code{port} (default: @code{6379})
|
@item @code{port} (default: @code{6379}) (type: number)
|
||||||
Port on which to accept connections on, a value of 0 will disable
|
Port on which to accept connections on, a value of 0 will disable
|
||||||
listening on a TCP socket.
|
listening on a TCP socket.
|
||||||
|
|
||||||
@item @code{working-directory} (default: @code{"/var/lib/redis"})
|
@item @code{working-directory} (default: @code{"/var/lib/redis"}) (type: string)
|
||||||
Directory in which to store the database and related files.
|
Directory in which to store the database and related files.
|
||||||
|
|
||||||
|
@item @code{config-file} (type: maybe-string)
|
||||||
|
Default location for config file.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
|
||||||
|
@c %end of fragment
|
||||||
|
|
||||||
@node Mail Services
|
@node Mail Services
|
||||||
@subsection Mail Services
|
@subsection Mail Services
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
(define-module (gnu services databases)
|
(define-module (gnu services databases)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
|
#:use-module (gnu services configuration)
|
||||||
#:use-module (gnu services shepherd)
|
#:use-module (gnu services shepherd)
|
||||||
#:use-module (gnu system shadow)
|
#:use-module (gnu system shadow)
|
||||||
#:autoload (gnu system accounts) (default-shell)
|
#:autoload (gnu system accounts) (default-shell)
|
||||||
@@ -786,19 +787,29 @@ port=" (number->string port) "
|
|||||||
;;; Redis
|
;;; Redis
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define-record-type* <redis-configuration>
|
(define-maybe string)
|
||||||
redis-configuration make-redis-configuration
|
|
||||||
redis-configuration?
|
(define (uglify-field-name field-name)
|
||||||
(redis redis-configuration-redis ;file-like
|
(string-delete #\? (symbol->string field-name)))
|
||||||
(default redis))
|
|
||||||
(bind redis-configuration-bind
|
(define (serialize-field field-name val)
|
||||||
(default "127.0.0.1"))
|
#~(format #f "~a=~a\n" #$(uglify-field-name field-name) #$val))
|
||||||
(port redis-configuration-port
|
|
||||||
(default 6379))
|
(define serialize-string serialize-field)
|
||||||
(working-directory redis-configuration-working-directory
|
(define serialize-number serialize-field)
|
||||||
(default "/var/lib/redis"))
|
|
||||||
(config-file redis-configuration-config-file
|
(define-configuration redis-configuration
|
||||||
(default #f)))
|
(redis (package redis)
|
||||||
|
"The Redis package to use.")
|
||||||
|
(bind (string "127.0.0.1")
|
||||||
|
"Network interface on which to listen.")
|
||||||
|
(port (number 6379)
|
||||||
|
"Port on which to accept connections on,
|
||||||
|
a value of 0 will disable listening on a TCP socket.")
|
||||||
|
(working-directory (string "/var/lib/redis")
|
||||||
|
"Directory in which to store the
|
||||||
|
database and related files.")
|
||||||
|
(config-file maybe-string "Default location for config file."))
|
||||||
|
|
||||||
(define (default-redis.conf bind port working-directory)
|
(define (default-redis.conf bind port working-directory)
|
||||||
(mixed-text-file "redis.conf"
|
(mixed-text-file "redis.conf"
|
||||||
@@ -832,7 +843,8 @@ port=" (number->string port) "
|
|||||||
(match-lambda
|
(match-lambda
|
||||||
(($ <redis-configuration> redis bind port working-directory config-file)
|
(($ <redis-configuration> redis bind port working-directory config-file)
|
||||||
(let ((config-file
|
(let ((config-file
|
||||||
(or config-file
|
(if (maybe-value-set? config-file)
|
||||||
|
config-file
|
||||||
(default-redis.conf bind port working-directory))))
|
(default-redis.conf bind port working-directory))))
|
||||||
(list (shepherd-service
|
(list (shepherd-service
|
||||||
(provision '(redis))
|
(provision '(redis))
|
||||||
@@ -857,3 +869,9 @@ port=" (number->string port) "
|
|||||||
(const %redis-accounts))))
|
(const %redis-accounts))))
|
||||||
(default-value (redis-configuration))
|
(default-value (redis-configuration))
|
||||||
(description "Run Redis, a caching key/value store.")))
|
(description "Run Redis, a caching key/value store.")))
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Generate documentation.
|
||||||
|
;;;
|
||||||
|
(define (redis-generate-doc)
|
||||||
|
(configuration->documentation 'redis-configuration))
|
||||||
|
|||||||
Reference in New Issue
Block a user