Search in sources :

Example 1 with IpcRequest

use of io.vertx.tp.ipc.eon.IpcRequest in project vertx-zero by silentbalanceyh.

the class UnitySpear method send.

@Override
public Future<Envelop> send(final Vertx vertx, final IpcData data) {
    // Channel
    final ManagedChannel channel = RpcSslTool.getChannel(vertx, data);
    final UnityServiceGrpc.UnityServiceVertxStub stub = UnityServiceGrpc.newVertxStub(channel);
    // Request
    final IpcRequest request = DataEncap.in(data);
    // Call and return to future
    final Future<Envelop> handler = Future.future();
    stub.unityCall(request, response -> RpcRepdor.create(getClass()).reply(handler, response));
    return handler;
}
Also used : Envelop(io.vertx.up.atom.Envelop) ManagedChannel(io.grpc.ManagedChannel) UnityServiceGrpc(io.vertx.tp.ipc.service.UnityServiceGrpc) IpcRequest(io.vertx.tp.ipc.eon.IpcRequest)

Example 2 with IpcRequest

use of io.vertx.tp.ipc.eon.IpcRequest in project vertx-zero by silentbalanceyh.

the class UnityTunnel method init.

@Override
public BindableService init(final Vertx vertx) {
    return new UnityServiceGrpc.UnityServiceVertxImplBase() {

        @Override
        public void unityCall(final IpcRequest request, final Future<IpcResponse> future) {
            // IpcData building
            final IpcData data = DataEncap.consume(request, IpcType.UNITY);
            // Method called with message handler
            final Envelop envelop = DataEncap.consume(data);
            // Method handle
            final Method method = IPCS.get(data.getAddress());
            // Work mode
            if (null == method) {
                // No Rpc Handler here
                final Envelop community = Envelop.failure(new _501RpcMethodMissingException(this.getClass(), data.getAddress()));
                // Build IpcData
                final IpcData responseData = UnityTunnel.this.build(community, envelop);
                future.complete(DataEncap.out(responseData));
            } else {
                // Execute Transit
                final Transit transit = UnityTunnel.this.getTransit(method, vertx);
                // Execute Transit
                final Future<Envelop> result = transit.async(envelop);
                result.setHandler(res -> {
                    final IpcData responseData = UnityTunnel.this.build(res.result(), envelop);
                    future.complete(DataEncap.out(responseData));
                });
            }
        }
    };
}
Also used : Envelop(io.vertx.up.atom.Envelop) Future(io.vertx.core.Future) Method(java.lang.reflect.Method) io.vertx.up.exception._501RpcMethodMissingException(io.vertx.up.exception._501RpcMethodMissingException) Transit(io.vertx.up.micro.ipc.tower.Transit) NodeTransit(io.vertx.up.micro.ipc.tower.NodeTransit) FinalTransit(io.vertx.up.micro.ipc.tower.FinalTransit) IpcRequest(io.vertx.tp.ipc.eon.IpcRequest) IpcData(io.vertx.up.atom.flux.IpcData)

Example 3 with IpcRequest

use of io.vertx.tp.ipc.eon.IpcRequest in project vertx-zero by silentbalanceyh.

the class UnityStub method traffic.

@Override
public Future<JsonObject> traffic(final IpcData data) {
    final UnityServiceGrpc.UnityServiceVertxStub stub = UnityServiceGrpc.newVertxStub(this.channel);
    // Request
    final IpcRequest request = DataEncap.in(data);
    // Call and return to future
    final Future<JsonObject> handler = Future.future();
    stub.unityCall(request, response -> RpcRepdor.create(this.getClass()).replyJson(handler, response));
    return handler;
}
Also used : UnityServiceGrpc(io.vertx.tp.ipc.service.UnityServiceGrpc) JsonObject(io.vertx.core.json.JsonObject) IpcRequest(io.vertx.tp.ipc.eon.IpcRequest)

Aggregations

IpcRequest (io.vertx.tp.ipc.eon.IpcRequest)3 UnityServiceGrpc (io.vertx.tp.ipc.service.UnityServiceGrpc)2 Envelop (io.vertx.up.atom.Envelop)2 ManagedChannel (io.grpc.ManagedChannel)1 Future (io.vertx.core.Future)1 JsonObject (io.vertx.core.json.JsonObject)1 IpcData (io.vertx.up.atom.flux.IpcData)1 io.vertx.up.exception._501RpcMethodMissingException (io.vertx.up.exception._501RpcMethodMissingException)1 FinalTransit (io.vertx.up.micro.ipc.tower.FinalTransit)1 NodeTransit (io.vertx.up.micro.ipc.tower.NodeTransit)1 Transit (io.vertx.up.micro.ipc.tower.Transit)1 Method (java.lang.reflect.Method)1