Search in sources :

Example 11 with DefaultEurekaClientConfig

use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.

the class DefaultEurekaClientConfigProviderTest method testNameSpaceInjection.

@Test
public void testNameSpaceInjection() throws Exception {
    ConfigurationManager.getConfigInstance().setProperty("testnamespace.serviceUrl.default", SERVICE_URI);
    Injector injector = LifecycleInjector.builder().withBootstrapModule(new BootstrapModule() {

        @Override
        public void configure(BootstrapBinder binder) {
            binder.bind(String.class).annotatedWith(EurekaNamespace.class).toInstance("testnamespace.");
        }
    }).build().createInjector();
    DefaultEurekaClientConfig clientConfig = injector.getInstance(DefaultEurekaClientConfig.class);
    List<String> serviceUrls = clientConfig.getEurekaServerServiceUrls("default");
    assertThat(serviceUrls.get(0), is(equalTo(SERVICE_URI)));
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) Injector(com.google.inject.Injector) LifecycleInjector(com.netflix.governator.guice.LifecycleInjector) BootstrapBinder(com.netflix.governator.guice.BootstrapBinder) BootstrapModule(com.netflix.governator.guice.BootstrapModule) Test(org.junit.Test)

Example 12 with DefaultEurekaClientConfig

use of com.netflix.discovery.DefaultEurekaClientConfig in project eureka by Netflix.

the class ExampleEurekaClient method main.

public static void main(String[] args) {
    ExampleEurekaClient sampleClient = new ExampleEurekaClient();
    // create the client
    ApplicationInfoManager applicationInfoManager = initializeApplicationInfoManager(new MyDataCenterInstanceConfig());
    EurekaClient client = initializeEurekaClient(applicationInfoManager, new DefaultEurekaClientConfig());
    // use the client
    sampleClient.sendRequestToServiceUsingEureka(client);
    // shutdown the client
    eurekaClient.shutdown();
}
Also used : DefaultEurekaClientConfig(com.netflix.discovery.DefaultEurekaClientConfig) MyDataCenterInstanceConfig(com.netflix.appinfo.MyDataCenterInstanceConfig) EurekaClient(com.netflix.discovery.EurekaClient) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager)

Aggregations

DefaultEurekaClientConfig (com.netflix.discovery.DefaultEurekaClientConfig)12 MyDataCenterInstanceConfig (com.netflix.appinfo.MyDataCenterInstanceConfig)7 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)6 DiscoveryClient (com.netflix.discovery.DiscoveryClient)5 EurekaClient (com.netflix.discovery.EurekaClient)4 EurekaInstanceConfig (com.netflix.appinfo.EurekaInstanceConfig)3 DefaultServerCodecs (com.netflix.eureka.resources.DefaultServerCodecs)3 Before (org.junit.Before)3 InstanceInfo (com.netflix.appinfo.InstanceInfo)2 DefaultEurekaServerConfig (com.netflix.eureka.DefaultEurekaServerConfig)2 EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)2 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)2 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)2 Injector (com.google.inject.Injector)1 AmazonInfo (com.netflix.appinfo.AmazonInfo)1 CloudInstanceConfig (com.netflix.appinfo.CloudInstanceConfig)1 EurekaConfigBasedInstanceInfoProvider (com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider)1 DynamicPropertyFactory (com.netflix.config.DynamicPropertyFactory)1 DiscoveryManager (com.netflix.discovery.DiscoveryManager)1 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)1