[Top][All Lists]

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

[bug#60788] [PATCH] services: Add vnstat-service-type.

From: Ludovic Courtès
Subject: [bug#60788] [PATCH] services: Add vnstat-service-type.
Date: Thu, 20 Apr 2023 12:09:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)


Bruno Victal <> skribis:

>>> +@item @code{database-dir} (default: @code{"/var/lib/vnstat"}) (type: 
>>> string)
>> [...]
>>> +@item @code{create-dirs?} (default: @code{#t}) (type: maybe-boolean)
>> For consistency, both within this record and with the rest of Guix, I
>> suggest avoiding abbreviations.  Since this will be part of the API,
>> better fix it now than later.
> I should mention that almost all of the field names here are near verbatim
> vnstat config-file directives, i.e. a near 1-1 Scheme translation of vnstat 
> config.
> This has the benefit that it makes serialization pretty much straightforward.
> It's possible to override their names by the use of the custom serializer 
> parameter
> but would it be acceptable to leave them as-is?

Hmm, I’d say that if the cost of using “nice names” is “really high”,
then yes.  But perhaps we can make that cost low by having a map for the
few cases where we use a name different from upstream?

  (define field-name-mapping
    '((database-directory . "database_dir") …))

> (define-module (gnu tests vnstat)

Woohoo, you rock!

>             (test-assert "vnstatd is logging"
>               ;; pump garbage into the "discard" service within the vm
>               ;; TODO: guile socket client instead? Is it feasible?
>               (let* ((socat #$(file-append socat "/bin/socat"))
>                      (dest-addr #$(format #f "TCP4:localhost:~d"
>                                           forwarded-port))
>                      (args `("socat" "-u" "/dev/zero" ,dest-addr))
>                      ;; XXX: Guile bug (22/03/2023, Guile 3.0.9)
>                      ;;      Fixed in main: 
> <>
>                      #;(output-port (%make-void-port "w"))
>                      (garbage-pump-pid (spawn socat args)))

You can probably connect directly to DEST-ADDR from Guile instead of
going through ‘socat’?

If not, you can either pass ‘#:guile guile-3.0-latest’ to
‘gexp->derivation’ so you get ‘spawn’ (3.0.9 is the default in
‘core-updates’ anyway), or use ‘primitive-fork’.



reply via email to

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