spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

Can't set server list from config #132

Closed yairogen closed 8 years ago

yairogen commented 8 years ago

I'm comparing Eureka VS Consul and I can't set the server list: ConsulServerList class from config as it doesn't have a default empty constructor.

In Eureka client and ribbon-core I used this:

myClient.ribbon.ribbon.NIWSServerListClassName=com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList

And this worked fine.

Trying this:

myClient.ribbon.ribbon.NIWSServerListClassName=org.springframework.cloud.consul.discovery.ConsulServerList

Fails on:

java.lang.NoSuchMethodException: org.springframework.cloud.consul.discovery.ConsulServerList.<init>()
spencergibb commented 8 years ago

ConsulServerList requires dependencies be injected by Spring. Why are you needing to do this? Using spring-cloud-consul should autowire ConsulServerList. Using @RibbonClient is how we wire spring classes into ribbon.

yairogen commented 8 years ago

I have an existing library that wraps rxnetty. This library is initialized using a factory api and doesn't impose spring injection as default as to not change backward compatibility. I'd expect spring consul support to follow the lines of spring cloud eureka support. The latter does support setting classes externally and configure them based on configuration rather than injection.

spencergibb commented 8 years ago

Not using spring injection is not currently a goal.

yairogen commented 8 years ago

@spencergibb is rxnetty supported by @RibbonClient?

spencergibb commented 8 years ago

We don't have any explicit support for rxnetty anywhere.

yairogen commented 8 years ago

Hence my need to support non injected clients as my customers need good async clients that use ribbon.

spencergibb commented 8 years ago

We support spring and spring-boot. There is work being done in the spring framework to support netty and reactive workflows.