Way to detect is "Discovery" service has been specified for a server / client?

Jan 28, 2011 at 5:32 PM

I am trying to create a generic method to locate remote workers but I need a way to determine whether I should use the DiscoverWorker() or ConnectWorker() method. Is there a property available from the XcoAppSpace class that I can use to determine if the space is configured to utilize a Discovery server (e.g. detect whether the "disco.address=discomachine:9000" string was passed into the space)?

Jan 29, 2011 at 9:15 AM

Hi husterk,

Currently there is no property for that, but you can find this out by checking if the XcoAppSpace instance contains an IXcoDiscoveryService instance. You could create e.g. an extension method like this:

public static bool HasDiscoveryService(this IXcoAppSpace space)
{
return (space.Info.ServiceRegistry.Resolve<IXcoDiscoveryService>() != null);
}

I will probably add this method to the next release of the discovery service, since it really seems useful.

Thomas

Jan 30, 2011 at 5:28 PM

Thanks thomass! This works perfectly.