use of org.apache.shenyu.register.server.api.ShenyuServerRegisterRepository in project incubator-shenyu by apache.
the class RegisterCenterConfiguration method shenyuServerRegisterRepository.
/**
* Shenyu server register repository server register repository.
*
* @param shenyuRegisterCenterConfig the shenyu register center config
* @param shenyuClientRegisterService the shenyu client register service
* @return the shenyu server register repository
*/
@Bean(destroyMethod = "close")
public ShenyuServerRegisterRepository shenyuServerRegisterRepository(final ShenyuRegisterCenterConfig shenyuRegisterCenterConfig, final List<ShenyuClientRegisterService> shenyuClientRegisterService) {
String registerType = shenyuRegisterCenterConfig.getRegisterType();
ShenyuServerRegisterRepository registerRepository = ExtensionLoader.getExtensionLoader(ShenyuServerRegisterRepository.class).getJoin(registerType);
RegisterServerDisruptorPublisher publisher = RegisterServerDisruptorPublisher.getInstance();
Map<String, ShenyuClientRegisterService> registerServiceMap = shenyuClientRegisterService.stream().collect(Collectors.toMap(ShenyuClientRegisterService::rpcType, e -> e));
publisher.start(registerServiceMap);
registerRepository.init(publisher, shenyuRegisterCenterConfig);
return registerRepository;
}
use of org.apache.shenyu.register.server.api.ShenyuServerRegisterRepository in project incubator-shenyu by apache.
the class RegisterCenterConfigurationTest method testShenyuServerRegisterRepository.
@Test
public void testShenyuServerRegisterRepository() {
ShenyuRegisterCenterConfig shenyuRegisterCenterConfig = mock(ShenyuRegisterCenterConfig.class);
List<ShenyuClientRegisterService> shenyuClientRegisterService = new ArrayList<>();
when(shenyuRegisterCenterConfig.getRegisterType()).thenReturn("http");
ShenyuServerRegisterRepository registerRepository = registerCenterConfiguration.shenyuServerRegisterRepository(shenyuRegisterCenterConfig, shenyuClientRegisterService);
assertNotNull(registerRepository);
}
Aggregations