Multiple implementation of the same object

Lionel Dricot zeploum at gmail.com
Tue Dec 2 05:42:01 PST 2008


Hello,

I want to use D-Bus to allow one "client" to get some information from a
"service" object. But this service object could be implemented multiple
times. I want to be able to just launch a new implementation of "service" in
the pool without having to change the "client" implementation at all. Client
should automatically use the the service with the highest priority.

One example will maybe be better to explain it :

Let say that I want to have the local temperature.

Service 1 read the temperature from a real thermometer outside of the
building.
Service 2 read the temperature from a meteorological website

I want program Service 1 to have a priority of 100. Service 2 is less
precize so it has a priorityy of 10.

client want to know the temperature :


Usecase 1 : both services are running
Client should automatically get the temperature from Service 1

Usecase 2 : Service 1 is down
Client will still retrieve the temperature and, without knowing it, will
retrieve it from Service 2.

Usercase 3: A new super thermometer is implemented as Service 3 with
priority 2000 (with service 1 and 2 still running)
This service 3 will just have to be launched and register itself to the same
session bus. Without any modification in Service1, 2 or client, client will
automatically use Service 3 if available.

Bonus Usecas 4: Service 1 adjust its priority automatically and decrease it
if values are abnormal or if the hardware is down
Client still use the highest priority so it fall back transparentely to
service 2.



Usecase 1,2 and 3 are mandatory for me. Usecase 4 is only an optionnal bonus
so it's really not important.

Is there a way to implement my usecase 1,2 and 3 with D-Bus with a few
complexity as possible on the client side ?


Currently, the only way I see is to have each service register on a bus
"Service.Temperature.$SERVICE_NBR" and to export the same object with the
same interface
On the client side, you could do :
    liste = bus.list_names()
    for i in liste :
        if i.startswith("Service.Temperature") :
            get_priority(i)
    use i with highest priority.


But it seems an highly ineffective method which a lot of complexity for the
client.

So, how would you do that ?

Thanks in advance for all the ideas,

Lionel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20081202/3d079e17/attachment.html 


More information about the dbus mailing list