pcp
[Top] [All Lists]

Service Discovery for PCP Clients

To: PCP <pcp@xxxxxxxxxxx>
Subject: Service Discovery for PCP Clients
From: Dave Brolley <brolley@xxxxxxxxxx>
Date: Tue, 19 Nov 2013 12:41:49 -0500
Delivered-to: pcp@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
Hi All,

I've just pushed the following to the brolley/dev branch in the pcpfans repository:

commit eaeb0678cf4e06c77a54cc7cd38401bc9bb250b2
Author: Dave Brolley <brolley@xxxxxxxxxx>
Date:   Tue Nov 19 12:04:14 2013 -0500

    Service discovery for PCP clients.
   
    - New libpcp API function __pmDiscoverServices()
      - Discovers services as requested.
      - Currently, only discovery of PMCD via Avahi is supported.
      - Related new API type: __pmServiceInfo.
      - Related new API functions: __pmServiceInfoAlloc(), __pmServiceInfoFree().
      - Related new API functions: __pmAddDisccoveredService(), __pmServiceListFree().
    - New __pmSockAddr API function: __pmSockAddrGetPort().
    - Added -p option to pminfo for prototype/testing purposes
      - not intended to be permanent, but can be, if wanted.
      - Instruct pminfo to use __pmDiscoverServices() to search for
        local PMCD servers.

I just want to add a few notes to the information in the commit message and to solicit review and comments.
  • The new __pmDiscoverServices() API is as was discussed on this list and on IRC. Not much to add in the way of notes for that one.

  • __pmServiceListFree() is to be used for freeing the list returned by __pmDiscoverService().

  • I exposed the data structure __pmServiceInfo along with the functions __pmServiceInfoAlloc(), __pmServiceInfoFree() and __pmAddDiscoveredService() in case there is a need for clients to manually add services which are known to them by other means than the supported discovery mechanisms (currently only PMCD via Avahi). If the consensus is that this is not needed, then we can easily hide them again.

  • Although __pmDiscoverServices() returns an array of urls as strings, __pmServiceInfo maintains the information as __pmSockAddr which I feel will be easier to work with internally once we start adding filters and other manipulations. __pmSockAddr is easily converted to a string at the end of it all using __pmSockAddrToString.

  • The new API function __pmSockAddrGetPort() was required in order to construct the urls.

  • I added a prototype option (-p) to pminfo just so that I could demonstrate that the new API is working. It can be removed at any time.

  • The urls returned for IPv6 PMCDs are similar to pcp://[fe80::5eff:35ff:fe07:55ca]:44321. That is, the address is enclosed in [] in order to separate the address from the port. This is a common notation among IPv6-enabled applications. Currently, PCP's url parser does not accept this notation. It should be an easy fix which I can have ready quickly.
Dave
<Prev in Thread] Current Thread [Next in Thread>