Digging into the Discovery Service

Sep 1, 2010 at 1:35 PM

I have been using the discovery service in a distributed application and it is working wonderfully. However, I would like to better understand the inner workings of this and also find out if it is possible to override some of the functionality (like you can with the Pub/Sub service). I would like to be able to detect when a new service registers it's workers with the disco server and when service requests to locate a specific service. That way, I would be able to detect when the entire system has been properly wired together. Any suggestions or thoughts on this? Also, I especially like the Fluent interface over the config string interface. Is there any way to define a disco service directly from the fluent interface?



Sep 3, 2010 at 4:12 PM

Hi, Keith!

Currently the disco service works like this: When an appspace instance starts up, and there is a discovery server address configured, it sends a registration message to this address. The discovery server space has a list of all registered appspace instances (it doesn't know though which workers are running on these space instances). When an appspace instance now wants to discover a worker, it sends a discovery request to the server (unless the worker is already registered locally). The server sends this discovery request to all registered appspace instances, which then give an appropriate response to the server. If a worker has been in any of the spaces, its address is returned to the space that sent the discovery request.

Concerning events for when a new space or worker is registered, or when a discovery request is sent, there is currently no functionality implemented for this. Though it would not be very hard to implement most of that (e.g. adding an XcoPublisher with OnSpaceRegistered and OnDiscoveryRequestArrived Messages to the DiscoveryWorker). What would be a bit more effort is to implement an event that a certain worker is available, because the discovery server doesn't get information about available workers, only about space instances. Overriding functions from outside like with the Pub/Sub feature is currently not possible.

Concerning fluent interface, there are currently not explicit methods like "OnPort", but you can just do this:
On the server side:
On the client Side:
.UsingService(new XcoDiscoveryService("servername:8000"))

There is no doubt that we will add more functionality to the discovery service in the future, probably including events like the ones you are looking for, but I cannot yet say when. In the meantime you can of course make additions yourself, if you have any more questions feel free to ask.

Hope I could help you!