Class RpcMethod<Req,Resp>

java.lang.Object
ru.pathcreator.pyc.rpc.core.RpcMethod<Req,Resp>
Type Parameters:
Req - тип запроса / request type
Resp - тип ответа / response type

public final class RpcMethod<Req,Resp> extends Object
Опциональная typed-обёртка над низкоуровневым API RpcChannel.

Optional typed method facade on top of the low-level RpcChannel API.

Этот класс не меняет поведение core transport-а. Это тонкая convenience wrapper-обёртка, которая оставляет снизу тот же raw путь через messageTypeId и codec.

This class does not change the core transport behavior. It is a thin convenience wrapper that keeps the raw message-type and codec path available underneath.

  • Method Details

    • of

      public static <Req,Resp> RpcMethod<Req,Resp> of(int requestMessageTypeId, int responseMessageTypeId, MessageCodec<Req> requestCodec, MessageCodec<Resp> responseCodec)
      Создаёт typed-описание одного RPC метода.

      Creates a typed description of one RPC method.

      Type Parameters:
      Req - request type
      Resp - response type
      Parameters:
      requestMessageTypeId - request message type id
      responseMessageTypeId - response message type id
      requestCodec - request codec
      responseCodec - response codec
      Returns:
      typed method descriptor
    • register

      public void register(RpcChannel channel, RequestHandler<Req,Resp> handler)
      Регистрирует handler этого метода на указанном канале.

      Registers this method's handler on the provided channel.

      Parameters:
      channel - channel to register on
      handler - typed request handler
    • call

      public Resp call(RpcChannel channel, Req request)
      Вызывает метод через указанный канал с default timeout канала.

      Calls the method through the provided channel using the channel default timeout.

      Parameters:
      channel - channel used for the call
      request - request payload
      Returns:
      decoded response
    • call

      public Resp call(RpcChannel channel, Req request, long timeout, TimeUnit unit)
      Вызывает метод через указанный канал с явным timeout.

      Calls the method through the provided channel using an explicit timeout.

      Parameters:
      channel - channel used for the call
      request - request payload
      timeout - timeout value
      unit - timeout unit
      Returns:
      decoded response
    • requestMessageTypeId

      public int requestMessageTypeId()
      Возвращает messageTypeId запроса.

      Returns the request message type id.

      Returns:
      request message type id
    • responseMessageTypeId

      public int responseMessageTypeId()
      Возвращает messageTypeId ответа.

      Returns the response message type id.

      Returns:
      response message type id
    • requestCodec

      public MessageCodec<Req> requestCodec()
      Возвращает codec запроса.

      Returns the request codec.

      Returns:
      request codec
    • responseCodec

      public MessageCodec<Resp> responseCodec()
      Возвращает codec ответа.

      Returns the response codec.

      Returns:
      response codec