net.dongliu.prettypb.rpc.config.ConfigServerProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prettypb-rpc Show documentation
Show all versions of prettypb-rpc Show documentation
proto rpc libs, compatible with proto-rpc-pro
package net.dongliu.prettypb.rpc.config;
import net.dongliu.prettypb.rpc.protocol.ServerInfo;
import java.util.*;
/**
* provide rpc servers by manual set
*
* @author Dong Liu
*/
public class ConfigServerProvider extends ServerProvider {
private List serverInfoList;
public ConfigServerProvider() {
serverInfoList = new ArrayList<>();
}
public ConfigServerProvider(ServerInfo... serverInfos) {
serverInfoList = Arrays.asList(serverInfos);
}
/**
* add new server
*/
public void addServer(ServerInfo serverInfo) {
this.serverInfoList.add(serverInfo);
serverChangedNotifier.notifyAdd(serverInfo);
}
/**
* remove server
*/
public void removeServer(ServerInfo serverInfo) {
this.serverInfoList.remove(serverInfo);
serverChangedNotifier.notifyRemove(serverInfo);
}
@Override
public Collection availableServers() {
return Collections.unmodifiableList(serverInfoList);
}
@Override
public void close() throws Exception {
}
}