On Tue, 17 Jun 2008, Thorvald Natvig wrote:
First, some RPC mechanisms support the idea of objects; instances of
interfaces that can be specifically addressed. If we, for example, were to
create an interface to administrate virtual servers for Apache, it is IMHO
much cleaner to
$object = $remote->getObject("/virtual.hostname");
$object->setServerAdmin("blahblah");
than
$remote->setServerAdmin("/virtual.hostname","blahblah");
(you'd have a bunch of methods, all of which start with the vhost parameter).
There's currently no way of doing this, as not all of the languages that
thrift supports have the concept of objects.
The way I'd recommend doing this is:
$hostRef = $remote->getObject("/virtual.hostname");
$remote->setServerAdmin($hostRef, "blahblah");
where $hostRef is an i64 that's unique and non-sequential.
It should be straightforward enough to implement this using a hashtable
of objects on the server and using a thin procedural layer to talk to an
OO instance on the backend.
Second, it often is very useful to know where a request came from and how we
got here. For example, it might be beneficial to limit the amount of requests
per second per source IP, and for that we'd need the context the call came
through. This could also be used to cache data on a per-client basis, and is
useful for logging. Is there an easy way to get this from inside the
interface implementation in your program?
To implement this you'd have to subclass the server. I'm not very familiar
with the cpp bindings, but I don't imagine it would be extremely
difficult.
Hope that helps,
-Todd