pcp
[Top] [All Lists]

Re: [pcp] pmServiceDiscoveryInterrupt() commit a8b87e2 et al.

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] pmServiceDiscoveryInterrupt() commit a8b87e2 et al.
From: Dave Brolley <brolley@xxxxxxxxxx>
Date: Tue, 08 Jul 2014 11:25:20 -0400
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <1374649635.181830.1404090114319.JavaMail.zimbra@xxxxxxxxxx>
References: <20140619194444.3B03D58015@xxxxxxxx> <53AB0F27.602@xxxxxxxxxx> <1063089485.33910956.1403758262805.JavaMail.zimbra@xxxxxxxxxx> <53AC35B8.3000802@xxxxxxxxxx> <1193390011.34470957.1403829231937.JavaMail.zimbra@xxxxxxxxxx> <1374649635.181830.1404090114319.JavaMail.zimbra@xxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
On 06/29/2014 09:01 PM, Nathan Scott wrote:
Thought of another possible approach over the weekend.  If we expect this
interface to need further change (given this is the second version of the
interface now, with more development being planned in discovery, we should
plan for it) we could use a versioned interface like pmGetOptions(3) and
his little friend, pmdaGetOptions(3).

That might look something like...

typedef struct {
     int         version;
     int         interrupted;      /* could become a flags bitfield? */
     const char  *globalOptions;   /* and this could be more explicit, */
                               /* instead of every possibly option being */
                               /* coerced into one comma-separated string? */
} pmDiscoveryOptions;

int
pmDiscoverServicesWithOptions(
     const char *service,
     const char *mechanism,
     pmDiscoveryOptions *options,
     char ***urls);

That API looks fairly neat to me and is a bit more future proof than
what we currently have.  As new extensions/requirements for the API
come along, using the version field & addition-to-end-of-struct-only
gives backwards compatibility almost for free (the libpcp code gets
to be simpler to extend internally too).

I ended up going with this approach. See the commit below. I ended up leaving 'interrupted' as an int because, currently, the interrupting signal number is stored there. The code does not examine it at this point, but I can see potential for this possibility down the road. I also anticipate this field being used to implement the upcoming global timeout and it might be useful to invent a code for that as well.

As suggested, 'globalOptions' is now broken into individual fields for individual options. Currently, only the 'resolve' option is represented and, since it is a boolean option, it is a single bit in a bitfield.

Dave

------------------------------

Author: Dave Brolley <brolley@xxxxxxxxxx>
Date:   Mon Jul 7 14:51:47 2014 -0400

Replace pmDiscoverServicesAdvanced(1) with pmDiscoverServicesWithOptions(1)

    New API takes a pointer pmServiceDiscoveryOptions which is a
    versioned struct describing the service discovery options.

<Prev in Thread] Current Thread [Next in Thread>