From: "Ludovic Courtès" <ludo@gnu.org>
To: Xinglu Chen <public@yoctocell.xyz>
Cc: 48976-done@debbugs.gnu.org, Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: bug#48976: [PATCH] services: configuration: Allow specifying prefix for serializer names.
Date: Tue, 29 Jun 2021 12:03:18 +0200 [thread overview]
Message-ID: <87sg11t2c9.fsf@gnu.org> (raw)
In-Reply-To: <78d519eab8503f4eadf9c57b9d3d4ee07de1450c.1623525052.git.public@yoctocell.xyz> (Xinglu Chen's message of "Sat, 12 Jun 2021 21:17:08 +0200")
Hi,
Xinglu Chen <public@yoctocell.xyz> skribis:
> Sometimes two configurations might have the same types for their field values,
> but the values might be serialized in two completely different
> ways (e.g. because the two programs have different configuration languages).
>
> An example of this would be the ‘serialize-boolean’ procedure in (gnu services
> mail) and (gnu services getmail). They both serialize a boolean value, but
> because the Dovecot’s configuration language has a different syntax to the
> configuration language for Getmail, two different procedures have to be
> defined.
>
> One way to workaround this would be to specify custom serializers for many
> fields in order to separate the serialization of the values that have the same
> type but serialize in different ways. This could get very tedious, especially
> if there are many configurations in the same module.
>
> Another way would be to move one of the configurations to its own module, like
> what was done with (gnu services getmail). However, this would mean that
> there would be multiple modules containing configurations for related
> programs, e.g. we have (gnu services mail) and (gnu services getmail), it
> doesn’t make much sense to keep the Getmail configuration in its own module.
>
> This patch will allow one to write something like this:
>
> (define-configuration foo-configuration
> (bar
> (string "bob")
> "Option bar.")
> (prefix bar-))
>
> and the value of the ‘bar’ field would be serialized using a procedure named
> ‘bar-serialize-string’ instead of just ‘serialize-string’.
>
> * gnu/services/configuration.scm (define-maybe-helper): Accept ‘prefix’
> argument for using serializer with custom prefix.
> (define-maybe): Pattern match on ‘prefix’ literal.
> (define-configuration-helper): Accept ‘prefix’ argument for using serializer
> with custom prefix.
> (define-configuration): Pattern match on ‘prefix’ literal.
> * tests/services/configuration.scm ("serialize-configuration with prefix"):
> New test.
Looks reasonable to me. Applied, thanks!
Ludo’.
prev parent reply other threads:[~2021-06-29 10:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 19:17 [bug#48976] [PATCH] services: configuration: Allow specifying prefix for serializer names Xinglu Chen
2021-06-29 10:03 ` Ludovic Courtès [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sg11t2c9.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=48976-done@debbugs.gnu.org \
--cc=maxim.cournoyer@gmail.com \
--cc=public@yoctocell.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.