All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.common.consul.configuration.ConsulAutoConfiguration Maven / Gradle / Ivy

Go to download

Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent

There is a newer version: 6.22.0
Show newest version
package com.nepxion.discovery.common.consul.configuration;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Congwei Xu * @version 1.0 */ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import com.ecwid.consul.v1.ConsulClient; import com.nepxion.discovery.common.consul.constant.ConsulConstant; import com.nepxion.discovery.common.consul.operation.ConsulOperation; import com.nepxion.discovery.common.exception.DiscoveryException; @Configuration public class ConsulAutoConfiguration { @Autowired private Environment environment; @Bean public ConsulOperation consulOperation() { return new ConsulOperation(); } @Bean @ConditionalOnMissingBean public ConsulClient consulClient() { String consulHost = environment.getProperty(ConsulConstant.CONSUL_HOST); if (StringUtils.isBlank(consulHost)) { throw new DiscoveryException(ConsulConstant.CONSUL_HOST + " can't be null or empty"); } int consulPort = environment.getProperty(ConsulConstant.CONSUL_PORT, Integer.class); return new ConsulClient(consulHost, consulPort); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy