spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.86k stars 2.44k forks source link

How to configure zuul router, ribbon and hytrix from database #3159

Closed ro9er closed 6 years ago

ro9er commented 6 years ago

Hi, My project has a requirement to configure router mappings in database so that my gateway application can fetch the configuration to register routers dynamically.I have gone through the previous issues and learned that I can inject my own ServerList Implementation in each ribbon client to update Server List from DB. And now I have another question. Can I configure the hytrix config for each ribbon client? I have viewed the source code and found the RibbonRouteFilter convert each forward request into a RibbonCommand which is a subclass of HytrixCommand. But I didn't found any sample about hytrix configuration for ribbon except this in http://cloud.spring.io/spring-cloud-static/Edgware.SR4/multi/multi__router_and_filter_zuul.html#netflix-zuul-reverse-proxy:

zuul: routes: echo: path: /myusers/** serviceId: myusers-service stripPrefix: true

hystrix: command: myusers-service: execution: isolation: thread: timeoutInMilliseconds: ...

myusers-service: ribbon: NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList listOfServers: http://example1.com,http://example2.com ConnectTimeout: 1000 ReadTimeout: 3000 MaxTotalHttpConnections: 500 MaxConnectionsPerHost: 100

Is there any document here to illustrate the hytrix config for one named ribbon client? And can I config it in database and fetch dynamically?

spencergibb commented 6 years ago

You can configure zuul with custom loader, see example here https://github.com/jmnarloch/zuul-route-cassandra-spring-cloud-starter

There is support for a jdbc repository in config server http://cloud.spring.io/spring-cloud-static/Finchley.SR1/single/spring-cloud.html#_jdbc_backend