Review and questions on the rest of the TODO items

Ray Lee ray-lk at madrabbit.org
Thu Jun 2 23:25:18 PDT 2005


(Saw this via p.g.o -- please forgive the lack of threading.)

> - need to define bus behavior if you send a message to 
>   yourself; is it an error, or allowed?

I suggest allowing this. It seems like I've written some sort of domain
specific message hub for nearly every project I've been involved in, and
it's always been useful to allow a message to be sent to oneself.

In one case, it was because during our prototyping and development, the
code didn't know (or care) whether the other endpoints it was
communicating with were on another machine, in another process space, or
statically linked to itself. The deployed code had to be able to work in
all those situations as well, so it wasn't just a debugging tool.

In another project, we had dynamic routing based on business logic for
which endpoint had to handle the (financial) transaction. Sometimes the
next endpoint in the path was the originator, because had the domain
specific knowledge to deal with whatever was coming down the pipe. Since
everything was in a specific financial packet format, it was easiest to
merely take the result of the db call for the routing decision, and
blindly shoot the packet off to the next person. (Which also simplified
the reception logic -- no need to write a queuing abstraction layer
internally to deal with messages from the hub sequenced with messages
from other code paths.)

In that same project there was a heartbeat daemon that sent echo
requests out to all the other daemons. The one it received from itself
let it know that the routing was working okay, and that it should hold
the other ends responsible for replies.

In general, allowing messages to yourself removes special casing from
the code (both the hub and its endpoints), it allows you to shoot off
control messages to other sections of your own code, or to even pull a
poor-man's monadic-style stunt where you queue up a sequence of work for
yourself, then process it, interleaved with whatever else comes down the
pipe concurrently.

In general, I think sending oneself a message from time to time is a
fine idea. As for whether or not it should be implemented for dbus
version 1.0, I'll leave that to someone who actually understands the
realities of the code base and the time frame.

> This would discourage people from writing wastefully code on methods
> that could just be called internally.

<shrug> Sure it could be more direct. But abstractions nearly always
have an associated cost. The question is, are the benefits they provide
worth the overhead? In this case I'd say yes.

One last point -- why do you feel you get to set policy on other
people's code that will use this? If it makes no real difference to
dbus, why not allow it and see what people can use it for? Arbitrarily
deciding something is bad and therefore must be discouraged isn't
usually all that productive. (And I've got a poor track record at
guessing at how clever people can be if you give them options, so I
inherently distrust myself on those sorts of decisions.)

 ~ ~

Offline for a friend's wedding 'til Monday. Please cc: any replies.

Ray

P.s. Thank you Havoc, John, and the rest for all your hard work. I
couldn't do what I do without the foundation that you all have provided
the community.




More information about the dbus mailing list