Skip to content

Plugging in your own InstanceDiscovery (1.x)

Trundle edited this page Oct 24, 2014 · 2 revisions

By default Turbine uses the Archaius config mechanism for understanding the list of instances to connect to. You can implement the InstanceDiscovery interface to get your own source of host info.

public interface InstanceDiscovery {
    
    /**
     * Fetch the collection of Instances.  
     * @return Collection<Instance>
     * @throws Exception
     */
    public Collection<Instance> getInstanceList() throws Exception;
}

You can register your config class with the PluginsFactory on server startup using the config property

InstanceDiscovery.impl=(canonical class name for your impl)

Note that if you need to pass your own args to your impl constructor, then you can also use Archaius to inject those as config, else you can manually register your impl in your webapp before server startup using

PluginsFactory.setInstanceDiscovery( impl );

and then call

TurbineInit.init();

Don't forget to tell Turbine how to connect to your hosts. This is covered in the Configuration section