use of io.vertx.up.eon.em.IpcType in project vertx-zero by silentbalanceyh.
the class RpcClientImpl method connect.
@Override
public RpcClient connect(final JsonObject config, final JsonObject data, final Handler<AsyncResult<JsonObject>> handler) {
final Record record = RpcHelper.getRecord(config);
// Service Configuration
final String name = config.getString(Key.NAME);
final String address = config.getString(Key.ADDR);
final JsonObject normalized = RpcHelper.normalize(name, config, record);
this.holder = this.lookupHolder(this.vertx, name, normalized);
// Get Channel
final IpcType type = Ut.toEnum(IpcType.class, config.getString(Key.TYPE));
final RpcStub stub = this.getStub(type);
// Future result return to client.
final IpcData request = new IpcData();
request.setType(type);
request.setAddress(address);
// The same operation for request.
DataEncap.in(request, record);
DataEncap.in(request, Envelop.success(data));
LOGGER.info(Info.CLIENT_TRAFFIC, request.toString());
final Future<JsonObject> future = stub.traffic(request);
future.setHandler(res -> handler.handle(Future.succeededFuture(res.result())));
return this;
}
use of io.vertx.up.eon.em.IpcType in project vertx-zero by silentbalanceyh.
the class TunnelClient method send.
public Future<Envelop> send(final Envelop envelop) {
// 1. Extract address
final String address = this.getValue("to");
final IpcType type = this.getValue("type");
// 2. Record extract
final Record record = this.findTarget();
// 3. Convert IpcData
final IpcData data = new IpcData();
data.setType(type);
data.setAddress(address);
// 4. In data
DataEncap.in(data, record);
DataEncap.in(data, envelop);
// 5. Stub
final Spear stub = STUBS.getOrDefault(type, Instance.singleton(UnitySpear.class));
return stub.send(this.vertx, data);
}
Aggregations