all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH Resend] services: dict.scm: Support more dicod configuration
@ 2017-03-07 11:47 Huang Ying
  2017-03-08 11:12 ` Huang, Ying
  2017-03-08 17:10 ` Ludovic Courtès
  0 siblings, 2 replies; 5+ messages in thread
From: Huang Ying @ 2017-03-07 11:47 UTC (permalink / raw)
  To: guix-devel

* gnu/services/dict.scm (<dicod-configuration>): Rename databases
  to items to reflect more general configuration.
  (<dicod-handler>): Add new record type to describe handler (module).
  (<dicod-database>): Add more fields.
  (dicod-configuration-file): Support convert more configuration items
  to config file.
---
 gnu/services/dict.scm | 50 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/gnu/services/dict.scm b/gnu/services/dict.scm
index 303067037..628ec9757 100644
--- a/gnu/services/dict.scm
+++ b/gnu/services/dict.scm
@@ -32,6 +32,7 @@
   #:export (dicod-service
             dicod-service-type
             dicod-configuration
+            dicod-handler
             dicod-database
             %dicod-database:gcide))
 
@@ -46,21 +47,29 @@
   (dico        dicod-configuration-dico       (default dico))
   (interfaces  dicod-configuration-interfaces     ;list of strings
                (default '("localhost")))
-  (databases   dicod-configuration-databases
-               ;; list of <dicod-database>
+  (items       dicod-configuration-items
+               ;; list of <dictod-handler> or <dicod-database>
                (default (list %dicod-database:gcide))))
 
+(define-record-type* <dicod-handler>
+  dicod-handler make-dicod-handler
+  dicod-handler?
+  (name        dicod-handler-name)
+  (module      dicod-handler-module          (default #f))
+  (options     dicod-handler-options         (default '())))
+
 (define-record-type* <dicod-database>
   dicod-database make-dicod-database
   dicod-database?
   (name        dicod-database-name)
-  (module      dicod-database-module)
+  (handler     dicod-database-handler)
+  (complex     dicod-database-complex        (default #f))
   (options     dicod-database-options        (default '())))
 
 (define %dicod-database:gcide
   (dicod-database
    (name "gcide")
-   (module "gcide")
+   (handler "gcide")
    (options (list #~(string-append "dbdir=" #$gcide "/share/gcide")
                   "idxdir=/var/run/dicod"))))
 
@@ -76,23 +85,44 @@
          (shell (file-append shadow "/sbin/nologin")))))
 
 (define (dicod-configuration-file config)
-  (define database->text
+  (define item->text
     (match-lambda
-      (($ <dicod-database> name module options)
+      (($ <dicod-handler> name #f '())
+       `("
+load-module " ,name ";"))
+      (($ <dicod-handler> name #f options)
+       (item->text (dicod-handler
+                    (name name)
+                    (module name)
+                    (options options))))
+      (($ <dicod-handler> name module options)
+       `("
+load-module " ,name " {
+   command \"" ,module (string-join (list ,@options) " " 'prefix) "\";
+}\n"))
+      (($ <dicod-database> name handler #f options)
+       (append
+        (item->text (dicod-handler
+                     (name handler)))
+        (item->text (dicod-database
+                     (name name)
+                     (handler handler)
+                     (complex #t)
+                     (options options)))))
+      (($ <dicod-database> name handler complex options)
        `("
-load-module " ,module ";
 database {
    name \"" ,name "\";
-   handler \"" ,module
+   handler \"" ,handler
    (string-join (list ,@options) " " 'prefix) "\";
 }\n"))))
 
   (define configuration->text
     (match-lambda
-      (($ <dicod-configuration> dico (interfaces ...) databases)
+      (($ <dicod-configuration> dico (interfaces ...) items)
        (append `("listen ("
                  ,(string-join interfaces ", ") ");\n")
-               (append-map database->text databases)))))
+               (append-map item->text items)))))
 
   (apply mixed-text-file "dicod.conf" (configuration->text config)))
 
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH Resend] services: dict.scm: Support more dicod configuration
  2017-03-07 11:47 [PATCH Resend] services: dict.scm: Support more dicod configuration Huang Ying
@ 2017-03-08 11:12 ` Huang, Ying
  2017-03-08 17:10 ` Ludovic Courtès
  1 sibling, 0 replies; 5+ messages in thread
From: Huang, Ying @ 2017-03-08 11:12 UTC (permalink / raw)
  To: Huang Ying; +Cc: guix-devel

Hi,

Can anyone help me to review this patch?

Best Regards,
Huang, Ying

Huang Ying <huang.ying.caritas@gmail.com> writes:

> * gnu/services/dict.scm (<dicod-configuration>): Rename databases
>   to items to reflect more general configuration.
>   (<dicod-handler>): Add new record type to describe handler (module).
>   (<dicod-database>): Add more fields.
>   (dicod-configuration-file): Support convert more configuration items
>   to config file.
> ---
>  gnu/services/dict.scm | 50 ++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/gnu/services/dict.scm b/gnu/services/dict.scm
> index 303067037..628ec9757 100644
> --- a/gnu/services/dict.scm
> +++ b/gnu/services/dict.scm
> @@ -32,6 +32,7 @@
>    #:export (dicod-service
>              dicod-service-type
>              dicod-configuration
> +            dicod-handler
>              dicod-database
>              %dicod-database:gcide))
>  
> @@ -46,21 +47,29 @@
>    (dico        dicod-configuration-dico       (default dico))
>    (interfaces  dicod-configuration-interfaces     ;list of strings
>                 (default '("localhost")))
> -  (databases   dicod-configuration-databases
> -               ;; list of <dicod-database>
> +  (items       dicod-configuration-items
> +               ;; list of <dictod-handler> or <dicod-database>
>                 (default (list %dicod-database:gcide))))
>  
> +(define-record-type* <dicod-handler>
> +  dicod-handler make-dicod-handler
> +  dicod-handler?
> +  (name        dicod-handler-name)
> +  (module      dicod-handler-module          (default #f))
> +  (options     dicod-handler-options         (default '())))
> +
>  (define-record-type* <dicod-database>
>    dicod-database make-dicod-database
>    dicod-database?
>    (name        dicod-database-name)
> -  (module      dicod-database-module)
> +  (handler     dicod-database-handler)
> +  (complex     dicod-database-complex        (default #f))
>    (options     dicod-database-options        (default '())))
>  
>  (define %dicod-database:gcide
>    (dicod-database
>     (name "gcide")
> -   (module "gcide")
> +   (handler "gcide")
>     (options (list #~(string-append "dbdir=" #$gcide "/share/gcide")
>                    "idxdir=/var/run/dicod"))))
>  
> @@ -76,23 +85,44 @@
>           (shell (file-append shadow "/sbin/nologin")))))
>  
>  (define (dicod-configuration-file config)
> -  (define database->text
> +  (define item->text
>      (match-lambda
> -      (($ <dicod-database> name module options)
> +      (($ <dicod-handler> name #f '())
> +       `("
> +load-module " ,name ";"))
> +      (($ <dicod-handler> name #f options)
> +       (item->text (dicod-handler
> +                    (name name)
> +                    (module name)
> +                    (options options))))
> +      (($ <dicod-handler> name module options)
> +       `("
> +load-module " ,name " {
> +   command \"" ,module (string-join (list ,@options) " " 'prefix) "\";
> +}\n"))
> +      (($ <dicod-database> name handler #f options)
> +       (append
> +        (item->text (dicod-handler
> +                     (name handler)))
> +        (item->text (dicod-database
> +                     (name name)
> +                     (handler handler)
> +                     (complex #t)
> +                     (options options)))))
> +      (($ <dicod-database> name handler complex options)
>         `("
> -load-module " ,module ";
>  database {
>     name \"" ,name "\";
> -   handler \"" ,module
> +   handler \"" ,handler
>     (string-join (list ,@options) " " 'prefix) "\";
>  }\n"))))
>  
>    (define configuration->text
>      (match-lambda
> -      (($ <dicod-configuration> dico (interfaces ...) databases)
> +      (($ <dicod-configuration> dico (interfaces ...) items)
>         (append `("listen ("
>                   ,(string-join interfaces ", ") ");\n")
> -               (append-map database->text databases)))))
> +               (append-map item->text items)))))
>  
>    (apply mixed-text-file "dicod.conf" (configuration->text config)))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Resend] services: dict.scm: Support more dicod configuration
  2017-03-07 11:47 [PATCH Resend] services: dict.scm: Support more dicod configuration Huang Ying
  2017-03-08 11:12 ` Huang, Ying
@ 2017-03-08 17:10 ` Ludovic Courtès
  2017-03-09 11:51   ` Huang, Ying
  1 sibling, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2017-03-08 17:10 UTC (permalink / raw)
  To: Huang Ying; +Cc: guix-devel

Hello!

Sorry for the long delay.

Huang Ying <huang.ying.caritas@gmail.com> skribis:

> * gnu/services/dict.scm (<dicod-configuration>): Rename databases
>   to items to reflect more general configuration.
>   (<dicod-handler>): Add new record type to describe handler (module).
>   (<dicod-database>): Add more fields.
>   (dicod-configuration-file): Support convert more configuration items
>   to config file.

Looks like a nice addition!

>    (dico        dicod-configuration-dico       (default dico))
>    (interfaces  dicod-configuration-interfaces     ;list of strings
>                 (default '("localhost")))
> -  (databases   dicod-configuration-databases
> -               ;; list of <dicod-database>
> +  (items       dicod-configuration-items
> +               ;; list of <dictod-handler> or <dicod-database>
>                 (default (list %dicod-database:gcide))))

“Items” sounds very generic.  Would it make sense to instead keep
separate ‘databases’ and ‘handlers’ fields?

> +(define-record-type* <dicod-handler>
> +  dicod-handler make-dicod-handler
> +  dicod-handler?
> +  (name        dicod-handler-name)
> +  (module      dicod-handler-module          (default #f))
> +  (options     dicod-handler-options         (default '())))

In fact I would suggest “module” instead of “handler”, to stick to the
name that Dico uses already, IIUC.  WDYT?

One last thing: could you update guix.texi to mention this?  Adding an
example of how to use it would be ideal.

Thank you!

Ludo’.

PS: In the future you can send to guix-patches@gnu.org, which goes to
    <https://bugs.gnu.org/guix-patches> where it’s hopefully less likely
    to fall through the cracks.  ;-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Resend] services: dict.scm: Support more dicod configuration
  2017-03-08 17:10 ` Ludovic Courtès
@ 2017-03-09 11:51   ` Huang, Ying
  2017-03-09 12:45     ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Huang, Ying @ 2017-03-09 11:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

ludo@gnu.org (Ludovic Courtès) writes:

> Hello!
>
> Sorry for the long delay.
>
> Huang Ying <huang.ying.caritas@gmail.com> skribis:
>
>> * gnu/services/dict.scm (<dicod-configuration>): Rename databases
>>   to items to reflect more general configuration.
>>   (<dicod-handler>): Add new record type to describe handler (module).
>>   (<dicod-database>): Add more fields.
>>   (dicod-configuration-file): Support convert more configuration items
>>   to config file.
>
> Looks like a nice addition!
>
>>    (dico        dicod-configuration-dico       (default dico))
>>    (interfaces  dicod-configuration-interfaces     ;list of strings
>>                 (default '("localhost")))
>> -  (databases   dicod-configuration-databases
>> -               ;; list of <dicod-database>
>> +  (items       dicod-configuration-items
>> +               ;; list of <dictod-handler> or <dicod-database>
>>                 (default (list %dicod-database:gcide))))
>
> “Items” sounds very generic.  Would it make sense to instead keep
> separate ‘databases’ and ‘handlers’ fields?

OK.

>> +(define-record-type* <dicod-handler>
>> +  dicod-handler make-dicod-handler
>> +  dicod-handler?
>> +  (name        dicod-handler-name)
>> +  (module      dicod-handler-module          (default #f))
>> +  (options     dicod-handler-options         (default '())))
>
> In fact I would suggest “module” instead of “handler”, to stick to the
> name that Dico uses already, IIUC.  WDYT?

From dico documentation

http://puszcza.gnu.org.ua/software/dico/manual/html_node/dictorg.html

There may be multiple instances for one module.  And the "instance" is
called as "handler" in "database" configuration.  So I changed the name.
If we call "instance" as "module", we will need another name for the
"module" in "instance" configuration.

> One last thing: could you update guix.texi to mention this?  Adding an
> example of how to use it would be ideal.

Sure.  I just want to collect some comments before change the
documentation.

> Thank you!
>
> Ludo’.
>
> PS: In the future you can send to guix-patches@gnu.org, which goes to
>     <https://bugs.gnu.org/guix-patches> where it’s hopefully less likely
>     to fall through the cracks.  ;-)

Sure.  Thanks for pointing this out!

Best Regards,
Huang, Ying

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Resend] services: dict.scm: Support more dicod configuration
  2017-03-09 11:51   ` Huang, Ying
@ 2017-03-09 12:45     ` Ludovic Courtès
  0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2017-03-09 12:45 UTC (permalink / raw)
  To: Huang, Ying; +Cc: guix-devel

"Huang, Ying" <huang_ying_caritas@163.com> skribis:

> From dico documentation
>
> http://puszcza.gnu.org.ua/software/dico/manual/html_node/dictorg.html
>
> There may be multiple instances for one module.  And the "instance" is
> called as "handler" in "database" configuration.  So I changed the name.
> If we call "instance" as "module", we will need another name for the
> "module" in "instance" configuration.

Good point.  I see Dico’s documentation uses the terms “database”,
“handler”, and “modules”.

I’m not sufficiently familiar with these so I’ll let you look into it,
but I think what matters is to use the same terms as Dico’s
documentation.  We should not introduce separate concepts or slightly
different meanings.

Thank you,
Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-09 12:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07 11:47 [PATCH Resend] services: dict.scm: Support more dicod configuration Huang Ying
2017-03-08 11:12 ` Huang, Ying
2017-03-08 17:10 ` Ludovic Courtès
2017-03-09 11:51   ` Huang, Ying
2017-03-09 12:45     ` Ludovic Courtès

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.