help-serveez
[Top][All Lists]
Advanced

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

Re: [help-serveez] How does the config language stuff work?


From: Raimund 'Raimi' Jacob
Subject: Re: [help-serveez] How does the config language stuff work?
Date: Fri, 15 Nov 2002 00:36:19 +0100 (CET)

On 14 Nov 2002, Andreas Rottmann wrote:

hi!

(woohoo, non-spam life on this list :-)

> I recently discovered serveez and am using it to develop a P2P load
> distribution framework/application called DistWork (spreading
> compilation, audio/video compression, raytracing, ... over multiple
> hosts). My application will allow the user to configure various
> services out of a set of service types (a service would be, for
> example, "C compilation with the GNU C compiler version 2.95 for the
> linux-i386-elf target", service type "UNIXish C/C++ compiler").

i think marketing droids call that 'grid' nowadays :)

> Still here? OK. What I now want is the user to able to configure the
> services via guile, just as serveez does for the servers. So it would
> be very nice for me to have a short outline how this is done (I have
> quite some knowledge of the Guile C bindings, FYI) and if i can use
> the SVZ_REGISTER mechanism for my purposes. If not, I'd offer to
> extend this stuff so things like this are possible.

okay, i try to answer this, Stefan should correct me if i lie.

the idea is this: in C the configuration of a server (or whatever) is a
struct. this struct is specific for its use and is passed around as part
of the state if the server.

such a configuration struct contains values of different types: integers,
boolean values (disguised as int), strings, arrays of strings, arrays of
integers and such.

in guile, however, there is no 'struct'. the guile way (or rather one of 
the various) is to have a map (an alist) that associates some name with
some value.

the problem now is, how to map between those two representations. In C you
do not want waste time searching guile data structures for some boolean
flag, you just want to access a struct.

the SVZ_REGISTER_* thing is used to tell some function (i cannot find in
the source anymore, grrr) how to interpret an alist and fill a C
struct (with some values being optional and being very forgiving about 
strings and symbols). See the foo server on how to use it.

all those macros are from libserveez/server.h. aahhh.. i think
libserveez/server.c "svz_server_configure" is the entry point of the
magic. perhaps you want to have a look there.

as you can see the function is quite longish and we are lucky that we dont
have to touch it anymore :) but it's nice to have all those tuple-mapping
finished in one place (and with good errormessages, too :-)

i am not sure if you can easily re-use the function since it is used for
server configuration structs only. perhaps you can re-use the idea and
some code-snippets to implement a generic guile-struct <-> c-struct
converter with good error messages.

if you want to do this, i suggest to
1) define the data types you want to have available in C
   (Strings, various Integers, other numbers, arrays of values, maps,
    whatever)
2) define how this stuff has to look like in guile.
3) define how the C part has to tell your mapper what it wants
4) implement the mapper
5) dont forget the error messages (yes, i am obsessed with those)

again, i have to apologize for any misinformation above. i have done
nothing useful for serveez in quite some time now. i am glad that stefan
is so forgiving with me :) i was answering anyway since this stuff used to
be my baby (which oddly mutated into some strange creature i hardly
recognize anymore :-). i program way to much java lately...

Bye,
    Raimi

--
      __/\     _/\    _____/\.___/\
     /   /    /  /___/   ____/  __/\     Name    : Raimi
    /   /  __/    __/   / __/  / _\/     Contact : address@hidden
   /   /__/ /     \/   /_/_/  /_/        Visit   : http://www.lkcc.org
  /________/___/\._\._____/_____/\       3.141592653589793238462643383
  \._______\.__\/__/\.____\.____\/       27950288419716939937510582097






reply via email to

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