zeromq / pyre

Python port of Zyre
GNU Lesser General Public License v3.0
121 stars 52 forks source link

Obtaining Peers in Group #102

Closed Robinini closed 7 years ago

Robinini commented 8 years ago

Hello

Thanks for the Python Port - I'm using it in a University project at the moment. I would like to obtain a list of the current peers which are members of a specific group.

Pyre provides Pyre.peers() which seems to be an implementation of Zyre zyre_peers() (see below or https://github.com/zeromq/zyre#toc3-188) and according to my tests provides all peers.

Is there an implementation of Zyre zyre_peers_by_group() (see below or https://github.com/zeromq/zyre#toc3-188) which returns only peers which belong to this group?

If this is not implemented, could anyone recommend a way of achieving this?

Grateful for any assistance.

//  *** Draft method, for development use, may change without warning ***
    //  Return zlist of current peer ids.
    //  Caller owns return value and must destroy it when done.
    ZYRE_EXPORT zlist_t *
        zyre_peers (zyre_t *self);

    //  *** Draft method, for development use, may change without warning ***
    //  Return zlist of current peers of this group.
    //  Caller owns return value and must destroy it when done.
    ZYRE_EXPORT zlist_t *
        zyre_peers_by_group (zyre_t *self, const char *name);
sphaero commented 8 years ago

I don't think the draft methods are implemented in Pyre indeed. It's quite easy to add them though. A pull request is very welcomed!

Just mimic the method peers() in pyre.py: https://github.com/zeromq/pyre/blob/master/pyre/pyre.py#L201

And how that's handled in pyre_node.py: https://github.com/zeromq/pyre/blob/master/pyre/pyre_node.py#L236

You can just look at the same C files in zyre to see how it's handled there

Robinini commented 8 years ago

Thanks - will look into it. University should be able to support. May well be able to add some improvements after the project is closed. Thanks again all.