Re: Messenger API and subscriptions

2012-09-20 Thread Rafael Schloming
On Thu, Sep 20, 2012 at 1:44 PM, William Henry  wrote:

>
>
> - Original Message -
> > On Thu, Sep 20, 2012 at 12:32 PM, William Henry 
> > wrote:
> >
> > >
> > >
> > > - Original Message -
> > > > How about:
> > > >
> > > > int pn_messenger_subscribe(pn_messenger_t *messenger, const char
> > > > *source,
> > > > void* context);
> > >
> > > This one I like.  It makes a lot of sense.
> > >
> > > > void *pn_message_subscribe_context(pn_message_t *msg);
> > > >
> > >
> > > This one less so. I have to make an extra call after I receive the
> > > message. Then the implementation needs to do some sort of lookup.
> > >  I think
> > > it would be much more efficient if I had an API that returned the
> > > message
> > > and the context.
> > >
> >
> > I can't imagine there would be a significant difference in efficiency
> > in
> > any real world scenario. The internal mechanism to find the context
> > should
> > be exactly the same either way, and setting the context in an out
> > parameter
> > vs setting a slot on the message are both just pointer indirection.
>
> I didn't realize you were setting something in the message. So you would
> modify the message? That's ok?
>
> If it is then I'm good with that.
>
> My thinking was: you'd have the context when you received the message.
>  You'd have to look it up the other way. But if you set something when you
> receive it then is't more or less the same thing as what I was looking for.
>

Yeah, the way get works is that it just fills in the message object that
you pass it. The idea being that for high performance scenarios you can
reuse the same message object, e.g. call get to fill in the new message,
process it, and then call get again on that same message object.

--Rafael


Re: Messenger API and subscriptions

2012-09-20 Thread William Henry


- Original Message -
> On Thu, Sep 20, 2012 at 12:32 PM, William Henry 
> wrote:
> 
> >
> >
> > - Original Message -
> > > How about:
> > >
> > > int pn_messenger_subscribe(pn_messenger_t *messenger, const char
> > > *source,
> > > void* context);
> >
> > This one I like.  It makes a lot of sense.
> >
> > > void *pn_message_subscribe_context(pn_message_t *msg);
> > >
> >
> > This one less so. I have to make an extra call after I receive the
> > message. Then the implementation needs to do some sort of lookup.
> >  I think
> > it would be much more efficient if I had an API that returned the
> > message
> > and the context.
> >
> 
> I can't imagine there would be a significant difference in efficiency
> in
> any real world scenario. The internal mechanism to find the context
> should
> be exactly the same either way, and setting the context in an out
> parameter
> vs setting a slot on the message are both just pointer indirection.

I didn't realize you were setting something in the message. So you would modify 
the message? That's ok?

If it is then I'm good with that.

My thinking was: you'd have the context when you received the message.  You'd 
have to look it up the other way. But if you set something when you receive it 
then is't more or less the same thing as what I was looking for.

William

> The
> only difference would be the procedure call overhead associated with
> actually accessing the pointer stored inside the message, and if that
> starts being an issue then I think (a) we have much bigger trouble
> since
> that's how all the fields inside a message are accessed, and (b)
> we're
> totally awesome because we must have done an impossibly great job of
> optimizing the rest of the code for this to even show up on a
> profile. ;-)
> 
> --Rafael
> 


Re: Messenger API and subscriptions

2012-09-20 Thread Rafael Schloming
On Thu, Sep 20, 2012 at 12:32 PM, William Henry  wrote:

>
>
> - Original Message -
> > How about:
> >
> > int pn_messenger_subscribe(pn_messenger_t *messenger, const char
> > *source,
> > void* context);
>
> This one I like.  It makes a lot of sense.
>
> > void *pn_message_subscribe_context(pn_message_t *msg);
> >
>
> This one less so. I have to make an extra call after I receive the
> message. Then the implementation needs to do some sort of lookup.  I think
> it would be much more efficient if I had an API that returned the message
> and the context.
>

I can't imagine there would be a significant difference in efficiency in
any real world scenario. The internal mechanism to find the context should
be exactly the same either way, and setting the context in an out parameter
vs setting a slot on the message are both just pointer indirection. The
only difference would be the procedure call overhead associated with
actually accessing the pointer stored inside the message, and if that
starts being an issue then I think (a) we have much bigger trouble since
that's how all the fields inside a message are accessed, and (b) we're
totally awesome because we must have done an impossibly great job of
optimizing the rest of the code for this to even show up on a profile. ;-)

--Rafael


Re: Messenger API and subscriptions

2012-09-20 Thread William Henry


- Original Message -
> How about:
> 
> int pn_messenger_subscribe(pn_messenger_t *messenger, const char
> *source,
> void* context);

This one I like.  It makes a lot of sense.

> void *pn_message_subscribe_context(pn_message_t *msg);
> 

This one less so. I have to make an extra call after I receive the message. 
Then the implementation needs to do some sort of lookup.  I think it would be 
much more efficient if I had an API that returned the message and the context. 

William

> For C we can just leave it as NULL if we don't care about it and in
> the
> idiomatic APIs we can turn it into an optional argument.
> 
> --Rafael
> 
> On Wed, Sep 19, 2012 at 12:05 PM, William Henry 
> wrote:
> 
> >
> >
> > - Original Message -
> > >
> > >
> > > - Original Message -
> > > > Can we expose the subscription for an incoming message on the
> > > > messenger API in some way?
> > > >
> > >
> > > Motivation:
> > >
> > > I'm trying to integrate with another messaging API.  That API may
> > > handle incoming messages differently based on their notion of a
> > > subscription.  Currently I would have to parse an incoming
> > > message's
> > > address and try to match that with some list of subscription
> > > strings.
> > >
> > > It would be handier if I could just get something back form the
> > > API
> > > to help me track/lookup.
> > >
> >
> > More thoughts:
> >
> > What would be nice is two API additions.
> >
> > int pn_messenger_context_subscribe(pn_messenger_t *messenger, const
> > char
> > *source, void* context);
> > int pn_messenger_context_get(pn_messenger_t *messenger,
> > pn_message_t *msg,
> > void* context);
> >
> > The get would return the context for that message based on the
> > subscription.
> >
> > Or something like that.
> >
> > Thoughts?
> >
> > William
> >
> > > William
> > >
> > > >
> > > >
> > > >
> > > > William
> > >
> >
> 


Re: Messenger API and subscriptions

2012-09-19 Thread Rafael Schloming
How about:

int pn_messenger_subscribe(pn_messenger_t *messenger, const char *source,
void* context);
void *pn_message_subscribe_context(pn_message_t *msg);

For C we can just leave it as NULL if we don't care about it and in the
idiomatic APIs we can turn it into an optional argument.

--Rafael

On Wed, Sep 19, 2012 at 12:05 PM, William Henry  wrote:

>
>
> - Original Message -
> >
> >
> > - Original Message -
> > > Can we expose the subscription for an incoming message on the
> > > messenger API in some way?
> > >
> >
> > Motivation:
> >
> > I'm trying to integrate with another messaging API.  That API may
> > handle incoming messages differently based on their notion of a
> > subscription.  Currently I would have to parse an incoming message's
> > address and try to match that with some list of subscription
> > strings.
> >
> > It would be handier if I could just get something back form the API
> > to help me track/lookup.
> >
>
> More thoughts:
>
> What would be nice is two API additions.
>
> int pn_messenger_context_subscribe(pn_messenger_t *messenger, const char
> *source, void* context);
> int pn_messenger_context_get(pn_messenger_t *messenger, pn_message_t *msg,
> void* context);
>
> The get would return the context for that message based on the
> subscription.
>
> Or something like that.
>
> Thoughts?
>
> William
>
> > William
> >
> > >
> > >
> > >
> > > William
> >
>


Re: Messenger API and subscriptions

2012-09-19 Thread William Henry


- Original Message -
> 
> 
> - Original Message -
> > Can we expose the subscription for an incoming message on the
> > messenger API in some way?
> > 
> 
> Motivation:
> 
> I'm trying to integrate with another messaging API.  That API may
> handle incoming messages differently based on their notion of a
> subscription.  Currently I would have to parse an incoming message's
> address and try to match that with some list of subscription
> strings.
> 
> It would be handier if I could just get something back form the API
> to help me track/lookup.
>

More thoughts: 

What would be nice is two API additions. 

int pn_messenger_context_subscribe(pn_messenger_t *messenger, const char 
*source, void* context);
int pn_messenger_context_get(pn_messenger_t *messenger, pn_message_t *msg, 
void* context);

The get would return the context for that message based on the subscription.

Or something like that.

Thoughts?

William 
 
> William
> 
> > 
> > 
> > 
> > William
> 


Re: Messenger API and subscriptions

2012-09-18 Thread William Henry


- Original Message -
> Can we expose the subscription for an incoming message on the
> messenger API in some way?
> 

Motivation:

I'm trying to integrate with another messaging API.  That API may handle 
incoming messages differently based on their notion of a subscription.  
Currently I would have to parse an incoming message's address and try to match 
that with some list of subscription strings. 

It would be handier if I could just get something back form the API to help me 
track/lookup.

William

> 
> 
> 
> William