use of org.kin.rsocket.core.discovery.RSocketServiceInstance in project kin-rsocket-broker by huangjianqin.
the class DiscoveryServiceImpl method newServiceInstance.
/**
* 构建{@link RSocketServiceInstance}实例
*/
private RSocketServiceInstance newServiceInstance(RSocketEndpoint rsocketEndpoint) {
AppMetadata appMetadata = rsocketEndpoint.getAppMetadata();
RSocketServiceInstance serviceInstance = new RSocketServiceInstance();
serviceInstance.setInstanceId(appMetadata.getUuid());
serviceInstance.setServiceId(appMetadata.getName());
serviceInstance.setHost(appMetadata.getIp());
if (appMetadata.getWebPort() > 0) {
serviceInstance.setPort(appMetadata.getWebPort());
String schema = "http";
serviceInstance.setSecure(appMetadata.isSecure());
// todo 返回https时, http gate抛异常
// if (appMetadata.isSecure()) {
// schema = "https";
// }
serviceInstance.setSchema(schema);
// 返回web port
serviceInstance.setUri(schema + "://" + appMetadata.getIp() + ":" + appMetadata.getWebPort());
}
serviceInstance.setMetadata(appMetadata.getMetadata());
return serviceInstance;
}
use of org.kin.rsocket.core.discovery.RSocketServiceInstance in project kin-rsocket-broker by huangjianqin.
the class DiscoveryServiceImpl method getInstances.
@Override
public Flux<RSocketServiceInstance> getInstances(String appName) {
if (appName.equals(Symbols.BROKER)) {
// 支持查询broker集群信息
return Flux.fromIterable(rsocketBrokerManager.all()).filter(BrokerInfo::isActive).map(broker -> {
RSocketServiceInstance instance = new RSocketServiceInstance();
instance.setInstanceId(broker.getId());
instance.setHost(broker.getIp());
instance.setServiceId(Symbols.BROKER);
instance.setPort(broker.getPort());
instance.setSchema(broker.getSchema());
instance.setUri(broker.getUrl());
return instance;
});
}
return findServicesInstancesByAppName(appName);
}
Aggregations