[collectd] memcached:// support in curl plugin

Doug MacEachern Doug.MacEachern at hyperic.com
Fri Feb 27 00:29:56 CET 2009


Hi Florian,

> -----Original Message-----
> From: Florian Forster [mailto:octo at verplant.org]
> Sent: Tuesday, February 24, 2009 3:16 AM
> To: Doug MacEachern
> Cc: collectd at verplant.org
> Subject: Re: [collectd] memcached:// support in curl plugin
> 
> Hi Doug,
> 
> On Mon, Feb 23, 2009 at 01:03:48PM -0500, Doug MacEachern wrote:
> > I can also do this, just let me know which path you think is best:
> > - leave the patch as-is
> > - implement pluggable schemes
> > - a new plugin, memcachec? - and in the process see if we can
extract
> > any more re-usable utils.
> 
> that'd be awesome, I've already spent more time with the Java plugin
> than I initially planned to ;)
> 
> I'm afraid I don't understand what you mean with ``implement pluggable
> schemes'', though :/

Similar idea to plugging a struct Curl_handler into libcurl, but since
we can't do that have own layer to do something like:
register_url_handler(const char *scheme, int (*callback) (web_page_t
*wp));

Where the handler is dispatched on the url scheme://, if there isn't one
registered then fallback to curl (cc_read_page).
But might be more trouble than it's worth, not sure what other schemes
we'd want to plugin in this way.
What do you think, should I just implement memcachec as its own plugin
and leave curl.c alone?
 
> The though to make configuration handling easier has crossed my mind
> more than once already. Some
>   int oconfig_get_string_alloc (const oconfig_item_t *ci,
>       char **ret_string);
>   int oconfig_get_string_buffer (const oconfig_item_t *ci,
>       char *buffer, size_t buffer_size);
>   int oconfig_get_double (const oconfig_item_t *ci,
>       double *ret_double);
>   ...
> functions are easy write and may help in many cases.
> 
> But what I'd absolutely love (but have no idea how to do ``nice'')
> would be something like this:
>   int oconfig_get_struct (const oconfig_item_t *ci,
>       const oconfig_struct_description_t *desc,
>       (void *) &ret_struct, sizeof (ret_struct)); Obviously, the
> `oconfig_struct_description_t' part is tricky, especially with
> dynamically arrays, nested structs, and so on..
> 
> If you or anybody else has a clever idea, let me know :)

I like the idea.  Wonder if something similar to Apache httpd's struct
command_rec would do the trick here.  Have you looked at that before?
The structure essentially allows you to define the description: name,
how many args, callback and user-data.  With the simple directives,
user-data is a structure offset and callback one of
ap_set_{string,int,flag,file,etc}_slot.  And plugins would implement
their own callbacks for more complex config.





More information about the collectd mailing list