Netflix / ribbon

Ribbon is a Inter Process Communication (remote procedure calls) library with built in software load balancers. The primary usage model involves REST calls with various serialization scheme support.
Apache License 2.0
4.55k stars 1.24k forks source link

Proxying with Ribbon.from can't load named client properties #188

Open dstengle opened 9 years ago

dstengle commented 9 years ago

It appears that using Ribbon.from and a proxied interface doesn't allow you to configure through archaius properties (although you can write properties, which I don't quite understand the utility of).

It looks like you can do a builder that pulls from the configs the same as you would get a named restclient. Being able to do this with a proxied interface would be great.

allenxwang commented 9 years ago

You can do that with @ClientProperties. See

https://github.com/Netflix/ribbon/blob/master/ribbon-examples/src/main/java/com/netflix/ribbon/examples/rx/proxy/MovieService.java

The properties defined with such annotations will be exported to Archaius configuration manager.

dstengle commented 9 years ago

I want the properties to be read from archaius, not written to. I want an IClientConfig to be built from properties, not the other way around. Like the older code:

RestClient client = (RestClient) ClientFactory.getNamedClient("sample-client")

With @ClientProperties it's back to hard-coding things.

What about a @NamedClient / @NamedClientProperties annotation or something similar? It seems like the same config code is used underneath and ultimately it all comes back to an IClientConfig.

allenxwang commented 9 years ago

There is no explicit API to create named client using annotations. However, you can still have all configurations in Archaius and have the client created using Archaius properties. Here is an example:

https://github.com/Netflix/ribbon/blob/master/ribbon-examples/src/main/java/com/netflix/ribbon/examples/rx/proxy/RxMovieProxyExample.java

dstengle commented 9 years ago

This is perfect! I see the implementation in the ResourceGroup.java and how it is derived from the class' simple name in ProxyHttpResourceGroupFactory.java

I was getting geared up to try and do a patch for an annotation, but it looks like it isn't necessary.

Is there any way to contribute to documentation?