Mercurial > libervia-backend
diff src/memory/disco.py @ 2431:a9fac72825a2
memory (disco): added findServiceEntity helper method to get first service of a kind
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 15 Nov 2017 08:54:32 +0100 |
parents | 8b37a62336c3 |
children | 0046283a285d |
line wrap: on
line diff
--- a/src/memory/disco.py Sat Nov 11 18:39:26 2017 +0100 +++ b/src/memory/disco.py Wed Nov 15 08:54:32 2017 +0100 @@ -230,6 +230,16 @@ log.warning(_(u"Error while requesting [%(jid)s]: %(error)s") % {'jid': entity_jid.full(), 'error': failure_.getErrorMessage()}) + def findServiceEntity(self, client, category, type_, jid_=None): + """Helper method to find first available entity from findServiceEntities + + args are the same as for [findServiceEntities] + @return (jid.JID, None): found entity + """ + d = self.host.findServiceEntities(client, "pubsub", "service") + d.addCallback(lambda entities: entities.pop() if entities else None) + return d + def findServiceEntities(self, client, category, type_, jid_=None): """Return all available items of an entity which correspond to (category, type_)