Skip to content

Instantly share code, notes, and snippets.

@melardev
Created February 21, 2019 13:50
Show Gist options
  • Save melardev/ab00c1eee929656c6344bbde5f11e167 to your computer and use it in GitHub Desktop.
Save melardev/ab00c1eee929656c6344bbde5f11e167 to your computer and use it in GitHub Desktop.
Ribbon tutorial melardev.com
package com.melardev.cloud.ribbon.config;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RibbonConfiguration {
@Autowired
IClientConfig ribbonClientConfig;
@Bean
public IPing ribbonPing(IClientConfig config) {
return new PingUrl();
// ping the server to get some results, then run rules through the results.¿Which rules? see method below(weigh time)
}
@Bean
public IRule ribbonRule() {
return new WeightedResponseTimeRule();
// Measure the response time, select the one with smaller response time.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment