use of com.alibaba.rsocket.route.RoutingEndpoint in project alibaba-rsocket-broker by alibaba.
the class RSocketAutoConfiguration method rsocketUpstreamManager.
@Bean(initMethod = "init")
public UpstreamManager rsocketUpstreamManager(@Autowired RSocketRequesterSupport rsocketRequesterSupport) throws JwtTokenNotFoundException {
SmartLifecycleUpstreamManagerImpl upstreamManager = new SmartLifecycleUpstreamManagerImpl(rsocketRequesterSupport);
if (properties.getBrokers() != null && !properties.getBrokers().isEmpty()) {
if (properties.getJwtToken() == null || properties.getJwtToken().isEmpty()) {
throw new JwtTokenNotFoundException();
}
UpstreamCluster cluster = new UpstreamCluster(null, "*", null);
cluster.setUris(properties.getBrokers());
upstreamManager.add(cluster);
}
upstreamManager.setP2pServices(properties.getP2pServices());
if (properties.getRoutes() != null && !properties.getRoutes().isEmpty()) {
for (RoutingEndpoint route : properties.getRoutes()) {
UpstreamCluster cluster = new UpstreamCluster(route.getGroup(), route.getService(), route.getVersion());
cluster.setUris(route.getUris());
upstreamManager.add(cluster);
}
}
return upstreamManager;
}
Aggregations