package netflix.karyon.eureka;

import com.google.inject.AbstractModule;
import com.google.inject.binder.LinkedBindingBuilder;
import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.appinfo.providers.CloudInstanceConfigProvider;
import com.netflix.discovery.DiscoveryClient;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.EurekaNamespace;
import com.netflix.discovery.providers.DefaultEurekaClientConfigProvider;
import com.netflix.governator.guice.BootstrapModule;
import netflix.karyon.Karyon;

/**
 * Initialize Eureka, by binding the &quot;eureka.&quot; namespace and adding providers for EurekaClientConfig
 * and EurekaInstanceConfig.
 *
 * @author Nitesh Kant
 */
public class KaryonEurekaModule extends AbstractModule {

    @Override
    protected void configure() {
        bind(com.netflix.appinfo.HealthCheckHandler.class).to(EurekaHealthCheckHandler.class);
        bind(ApplicationInfoManager.class).asEagerSingleton();
        bind(DiscoveryClient.class).asEagerSingleton();

        configureEureka();
    }

    protected void configureEureka() {
        bindEurekaNamespace().toInstance("eureka.");
        bindEurekaInstanceConfig().toProvider(CloudInstanceConfigProvider.class);
        bindEurekaClientConfig().toProvider(DefaultEurekaClientConfigProvider.class);
    }

    protected LinkedBindingBuilder<EurekaInstanceConfig> bindEurekaInstanceConfig() {
        return bind(EurekaInstanceConfig.class);
    }

    protected LinkedBindingBuilder<EurekaClientConfig > bindEurekaClientConfig() {
        return bind(EurekaClientConfig.class);
    }

    protected LinkedBindingBuilder<String> bindEurekaNamespace() {
        return bind(String.class).annotatedWith(EurekaNamespace.class);
    }

    public static BootstrapModule asBootstrapModule() {
        return Karyon.toBootstrapModule(KaryonEurekaModule.class);
    }

}

@@ -817,16 +817,236 @@
 dule %7B%0A%0A
+    private final String eurekaNamespace;%0A%0A    public KaryonEurekaModule() %7B%0A        this(%22eureka.%22);%0A    %7D%0A%0A    public KaryonEurekaModule(String eurekaNamespace) %7B%0A        this.eurekaNamespace = eurekaNamespace;%0A    %7D%0A%0A
     @Ove
@@ -1413,25 +1413,31 @@
 nstance(
-%22
 eureka
-.%22
+Namespace
 );%0A     

Make Eureka namespace configurable in KaryonEurekaModule.