[ejabberd] PubSub API

Eric Cestari eric at ohmforce.com
Fri Sep 5 14:42:29 MSD 2008


While we are on the subject ...

I've written yesterday a PubSub node that pulls from a webservice  
subscriber and publisher information.
The code works fine, but I was not able to leverage the API as much as  
I would (except by copy/paste ...)

What I wish : building a module base on node_default and just have to  
"override"  the get_state/3 and get_states/2.

 From my understanding of the node_default code, I can already get  
tremendous flexibility, because those are the functions that define  
the subscriptions and affiliations.

Instead I had to copy paste a whole lot of functions  
get_*_subscription, get_*_affiliation, get_item, get_items,  
publish_item etc. with little or no modification.

I think there's room for improvement in the API, except that I'm not  
sure on the best way to architect that in erlang

When I have in my code :
get_items(Host, Node, JID, AccessModel, PresenceSubscription,  
RosterGroup, SubId) ->
     node_default:get_items(Host, Node, JID, AccessModel,  
PresenceSubscription, RosterGroup, SubId).

I'd like node_default:get_items/2 to call my own module's get_state.

However, couple of caveats :
- I don't have the best erlang solution to have this implemented  
elegantly. I was thinking of adding a new version of the main  
functions, ie :
	node_default:get_items(Host, Node, JID, AccessModel,  
PresenceSubscription, RosterGroup, SubId, ?MODULE).
	(or have a new node_pluggablestate module which would do just that ?)

- maybe my perspective is skewed, and that would be the first and last  
time I need such a feature, and it's a use case too rare to actually  
design something around.

What do you think ?

Eric



More information about the ejabberd mailing list