Search in sources :

Example 1 with RxHod

use of io.vertx.up.tool.container.RxHod in project vertx-zero by silentbalanceyh.

the class RpcHelper method getRecord.

static Record getRecord(final JsonObject config) {
    /**
     * Config Verify *
     */
    Fn.flingUp(() -> Fn.shuntZero(() -> Ruler.verify(Key.RULE_KEY, config), config), LOGGER);
    // Connect remote etcd to check service
    final ConcurrentMap<String, Record> registryData = ORIGIN.getRegistryData();
    final String name = config.getString(Key.NAME);
    final String address = config.getString(Key.ADDR);
    LOGGER.debug(Info.RPC_SERVICE, name, address);
    // Empty Found
    Fn.flingWeb(registryData.values().isEmpty(), LOGGER, _424RpcServiceException.class, RpcHelper.class, name, address);
    // Service status checking
    final RxHod container = new RxHod();
    // Lookup Record instance
    Observable.fromIterable(registryData.values()).filter(Objects::nonNull).filter(item -> Ut.notNil(item.getName())).filter(item -> name.equals(item.getName()) && address.equals(item.getMetadata().getString(Key.PATH))).subscribe(container::add);
    // Service Not Found
    Fn.flingWeb(!container.successed(), LOGGER, _424RpcServiceException.class, RpcHelper.class, name, address);
    // Address Not Found
    Fn.flingWeb(!container.successed(), LOGGER, _424RpcServiceException.class, RpcHelper.class, name, address);
    final Record record = container.get();
    LOGGER.debug(Info.RPC_FOUND, record.toJson());
    return container.get();
}
Also used : io.vertx.up.exception._424RpcServiceException(io.vertx.up.exception._424RpcServiceException) Fn(io.vertx.up.func.Fn) Origin(io.vertx.up.micro.discovery.Origin) RxHod(io.vertx.up.tool.container.RxHod) Ut(io.vertx.up.tool.Ut) Ruler(io.vertx.zero.atom.Ruler) IpcType(io.vertx.up.eon.em.IpcType) Record(io.vertx.servicediscovery.Record) Instance(io.vertx.up.tool.mirror.Instance) ConcurrentMap(java.util.concurrent.ConcurrentMap) Objects(java.util.Objects) IpcOrigin(io.vertx.up.micro.discovery.IpcOrigin) Annal(io.vertx.up.log.Annal) Observable(io.reactivex.Observable) JsonObject(io.vertx.core.json.JsonObject) Record(io.vertx.servicediscovery.Record) RxHod(io.vertx.up.tool.container.RxHod)

Aggregations

Observable (io.reactivex.Observable)1 JsonObject (io.vertx.core.json.JsonObject)1 Record (io.vertx.servicediscovery.Record)1 IpcType (io.vertx.up.eon.em.IpcType)1 io.vertx.up.exception._424RpcServiceException (io.vertx.up.exception._424RpcServiceException)1 Fn (io.vertx.up.func.Fn)1 Annal (io.vertx.up.log.Annal)1 IpcOrigin (io.vertx.up.micro.discovery.IpcOrigin)1 Origin (io.vertx.up.micro.discovery.Origin)1 Ut (io.vertx.up.tool.Ut)1 RxHod (io.vertx.up.tool.container.RxHod)1 Instance (io.vertx.up.tool.mirror.Instance)1 Ruler (io.vertx.zero.atom.Ruler)1 Objects (java.util.Objects)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1