[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] improve nginx-service
From: |
Clément Lassieur |
Subject: |
Re: [PATCH] improve nginx-service |
Date: |
Fri, 25 Nov 2016 11:53:31 +0100 |
User-agent: |
mu4e 0.9.16; emacs 25.1.1 |
> I've been rethinking it, and I would like to use define-configuration
> (from cups and dovecot) because it looks really good. But I don't want
> to define the same config option for each possible block it can appear
> in, and that's why I used (option). So I'm looking for a way to
> dynamically define records for each block type, so they can be used more
> consistently with what we have. Unfortunately, I don't see how I could
> do that, if that is possible at all... Ludo, any idea? I'd like to be
> able to write:
>
> (define-record-type* <nginx-option>
> ...)
>
> (define-syntax option
> (syntax-rule ()
> (option mname mtype mdef mdoc mblocks))
> (nginx-option (name mname) (type mtype) ...)))
>
> (define option-list (list
> (option 'server-name server-name 'default "the name of the server that
> is served by the http block" (list 'http))
> ...))
>
> and then be able to create the block records by filtering that list:
>
> (define-nginx-configuration nginx-http-block
> (filter ... option-list))
>
> (define-nginx-configuration nginx-events-block
> (filter ... option-list))
>
> (define-nginx-configuration nginx-server-block
> (filter ... option-list))
>
> So the user would then be able to write the service configuration as
> they would for any other service we have. What I don't know is how to
> write define-nginx-configuration (ideally it would call
> define-configuration). With it, I can probably do the rest just fine. Or
> maybe there is a better way I don't see yet?
I think you are looking for "eval".
(define (list->define-configuration stem fields)
(eval `(define-configuration ,stem ,@fields) (current-module)))
(list->define-configuration 'some-configuration filtered-list)
I use it in a service I'm working on (Prosody), to handle virtualhosts.
- Re: [PATCH] improve nginx-service, (continued)
- Re: [PATCH] improve nginx-service, Hartmut Goebel, 2016/11/04
- Re: [PATCH] improve nginx-service, Tobias Geerinckx-Rice, 2016/11/06
- Re: [PATCH] improve nginx-service, Ludovic Courtès, 2016/11/06
- Re: [PATCH] improve nginx-service, Julien Lepiller, 2016/11/20
- Re: [PATCH] improve nginx-service, Hartmut Goebel, 2016/11/22
- Re: [PATCH] improve nginx-service, julien lepiller, 2016/11/23
- Re: [PATCH] improve nginx-service,
Clément Lassieur <=
- is using eval good style in guile?(was: [PATCH] improve nginx-service), Hartmut Goebel, 2016/11/25
- Re: is using eval good style in guile?, Andy Wingo, 2016/11/25
- Re: is using eval good style in guile?, Clément Lassieur, 2016/11/26
- Re: [PATCH] improve nginx-service, Ludovic Courtès, 2016/11/27
- Re: [PATCH] improve nginx-service, Ludovic Courtès, 2016/11/06