mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 03:55:08 -06: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:
parent
b00a27c427
commit
4b25873c12
2 changed files with 56 additions and 21 deletions
|
|
@ -28343,30 +28343,47 @@ Additional command line options to pass to @code{memcached}.
|
|||
|
||||
@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
|
||||
This is the service type for the @uref{https://redis.io/, Redis}
|
||||
key/value store, whose value is a @code{redis-configuration} object.
|
||||
Type of the service that runs @command{redis}, an in-memory data store.
|
||||
The value for this service is a @code{<redis-configuration>} object.
|
||||
@end defvar
|
||||
|
||||
@c %start of fragment
|
||||
|
||||
@deftp {Data Type} redis-configuration
|
||||
Data type representing the configuration of redis.
|
||||
Available @code{redis-configuration} fields are:
|
||||
|
||||
@table @asis
|
||||
@item @code{redis} (default: @code{redis})
|
||||
@item @code{redis} (default: @code{redis}) (type: package)
|
||||
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.
|
||||
|
||||
@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
|
||||
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.
|
||||
|
||||
@item @code{config-file} (type: maybe-string)
|
||||
Default location for config file.
|
||||
|
||||
@end table
|
||||
|
||||
@end deftp
|
||||
|
||||
|
||||
@c %end of fragment
|
||||
|
||||
@node Mail Services
|
||||
@subsection Mail Services
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
(define-module (gnu services databases)
|
||||
#:use-module (gnu services)
|
||||
#:use-module (gnu services configuration)
|
||||
#:use-module (gnu services shepherd)
|
||||
#:use-module (gnu system shadow)
|
||||
#:autoload (gnu system accounts) (default-shell)
|
||||
|
|
@ -786,19 +787,29 @@ port=" (number->string port) "
|
|||
;;; Redis
|
||||
;;;
|
||||
|
||||
(define-record-type* <redis-configuration>
|
||||
redis-configuration make-redis-configuration
|
||||
redis-configuration?
|
||||
(redis redis-configuration-redis ;file-like
|
||||
(default redis))
|
||||
(bind redis-configuration-bind
|
||||
(default "127.0.0.1"))
|
||||
(port redis-configuration-port
|
||||
(default 6379))
|
||||
(working-directory redis-configuration-working-directory
|
||||
(default "/var/lib/redis"))
|
||||
(config-file redis-configuration-config-file
|
||||
(default #f)))
|
||||
(define-maybe string)
|
||||
|
||||
(define (uglify-field-name field-name)
|
||||
(string-delete #\? (symbol->string field-name)))
|
||||
|
||||
(define (serialize-field field-name val)
|
||||
#~(format #f "~a=~a\n" #$(uglify-field-name field-name) #$val))
|
||||
|
||||
(define serialize-string serialize-field)
|
||||
(define serialize-number serialize-field)
|
||||
|
||||
(define-configuration redis-configuration
|
||||
(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)
|
||||
(mixed-text-file "redis.conf"
|
||||
|
|
@ -832,7 +843,8 @@ port=" (number->string port) "
|
|||
(match-lambda
|
||||
(($ <redis-configuration> redis bind port working-directory config-file)
|
||||
(let ((config-file
|
||||
(or config-file
|
||||
(if (maybe-value-set? config-file)
|
||||
config-file
|
||||
(default-redis.conf bind port working-directory))))
|
||||
(list (shepherd-service
|
||||
(provision '(redis))
|
||||
|
|
@ -857,3 +869,9 @@ port=" (number->string port) "
|
|||
(const %redis-accounts))))
|
||||
(default-value (redis-configuration))
|
||||
(description "Run Redis, a caching key/value store.")))
|
||||
|
||||
;;;
|
||||
;;; Generate documentation.
|
||||
;;;
|
||||
(define (redis-generate-doc)
|
||||
(configuration->documentation 'redis-configuration))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue