-
Configurable service discovery and registry
-
Pluggable loadbalancing
-
Auto discovery services and clients
-
Distributed tracing
-
Http and idl wire protocl like thrift, protobuf
-
Asynchronous io, parallel execution, request pipelining
-
Connection pooling
-
Automatic reconnection
Define data types and services in a thrift definition file
Leverage JAX-RS annotations
Define data types and services in a proto definition file
Your service discovery needs to implemment interface ServiceDiscovery:
public List<InetSocketAddress> getServerList(String service, String proto) throws IOException;
Your service registry needs to implement interface ServiceRegistration:
public void registerServer(String service, String proto, InetSocketAddress address);
public ListenableFuture<?> unregisterServer(String service, String proto, InetSocketAddress address);
Currently EtcdServiceDiscovery and EtcdServiceRegistration provided
Your custom load balancing needs to implment interface LoadBalancingPolicy:
public interface LoadBalancingPolicy extends Host.StateListener {
public Iterator<Host> queryPlan();
public void init(Collection<Host> hosts);
}
Currentlty RoundRobinPolicy provided
Your custom client interceptors need to implement interface ClientInterceptor:
public <T extends IRequest, V extends IResponse> Connection.ResponseCallback<T, V> intercept(Connection.ResponseCallback<T, V> request);
Your custom server interceptors need to implement interface ServerInterceptor:
public void preProcess(String fullMethod, SocketAddress address, Map<String, String> header);
public void postProcess(Exception e);
We provide BraveRpcClientInterceptor and BraveRpcServerInterceptor out of the box to collect the tracing information and send them to Zipkin.
All you need to do is to set up service discovery and registration, then services implemented will be discovered and called by clients
Refer to test/java/cn/v5/lbrpc/thrfit/ThriftShortHandTest.java
If you want to turn tracing on, refer to test/java/cn/v5/lbrpc/thrfit/BraveRpcInterceptorsTest
Refer to test/java/cn/v5/lbrpc/http/HttpShortHandTest.java
If you want to turn tracing on, refer to test/java/cn/v5/lbrpc/http/BraveHttpInterceptorsTest