[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: artanis.conf user defined variables

From: Mortimer Cladwell
Subject: Re: artanis.conf user defined variables
Date: Mon, 13 Dec 2021 13:55:00 -0500

Thanks Nala, I got it working. Convenient.
What do you mean "You have to verify the items like artanis/config.scm."?

On Sat, Dec 11, 2021 at 12:34 PM Nala Ginrut <> wrote:

Hi Mortimer!
If "maxnumwidgets" is your custom variable, you may follow these principles:

1. You shouldn't patch artanis/config.scm to add app specific config.

2. You can take advantage of config API to provide configs to your
users, say, get-conf and conf-set!.

3. You have to put your custom config somewhere, say
app/config/myconfig.scm. Parse and add them with conf-set! in
initialization in ENTRY file.

4. You have to verify the items like artanis/config.scm.

5. The conf-set! is global, so it's unsafe for each session. If you want
to keep config for each session, please use LPC, see artanis/lpc.scm

Best regards.

Mortimer Cladwell writes:

> Hi Nala,
> My artanis app makes use of a custom variable, let's call it
> "maxnumwidgets", that I would like to include in artanis.conf to give the
> users an easy way to configure.  Currently I do this by modifying the
> source during install with the following snippet in the guix packaging
> recipe:
>  (substitute* "artanis/config.scm"
>       ((" \\(else \\(error parse-namespace-cache \"Config: Invalid item\"
> item\\)\\)\\)\\)")
> "(else (error parse-namespace-cache \"Config: Invalid item\"
> item))))\n\n(define (parse-namespace-cookie item)\n  (match item\n
>  (('expire expire) (conf-set! '(cookie expire) (->integer expire)))\n
>  (('maxnumwidgets maxnumwidgets) (conf-set! '(cookie maxnumwidgets)
> (->integer maxnumwidgets)))\n    (else (error parse-namespace-cookie
> \"Config: Invalid item\" item))))"))
> maxnumwidgets is not a cookie.  I put it in the cookie group for
> convenience.  I can imagine an artanis.conf section that looks like:
> ##user defined variables
> ##user.var1 = <string>
> ##user.var2 = <string>
> ##user.var3 = <string>
> ##user.var4 = <integer>
> ##user.var5 = <integer>
> ##user.var6 = <integer>
> This would provide the developer with a few configurable variables that
> don't require modification of the source code.  The developer would have to
> document the meaning of each variable, for example I would have to indicate
> in documentation that user.var1 == maxnumwidgets.  I can write the source
> modifications and create a pull request, but don't want to put in the
> effort unless you are interested. Let me know.
> Thanks
> Mortimer

GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
Fingerprint F53B 4C56 95B5 E4D5 6093 4324 8469 6772 846A 0058

reply via email to

[Prev in Thread] Current Thread [Next in Thread]