Interface Result

All Superinterfaces:
Serializable
All Known Implementing Classes:
AppResponse, AsyncRpcResult

public interface Result extends Serializable
(API, Prototype, NonThreadSafe) An RPC Result. Known implementations are: 1. AsyncRpcResult, it's a CompletionStage whose underlying value signifies the return value of an RPC call. 2. AppResponse, it inevitably inherits CompletionStage and Future, but you should never treat AppResponse as a type of Future, instead, it is a normal concrete type.
See Also:
  • Method Details

    • getValue

      Object getValue()
      Get invoke result.
      Returns:
      result. if no result return null.
    • setValue

      void setValue(Object value)
    • getException

      Throwable getException()
      Get exception.
      Returns:
      exception. if no exception return null.
    • setException

      void setException(Throwable t)
    • hasException

      boolean hasException()
      Has exception.
      Returns:
      has exception.
    • recreate

      Object recreate() throws Throwable
      Recreate.

      if (hasException()) { throw getException(); } else { return getValue(); }

      Returns:
      result.
      Throws:
      Throwable
    • getAttachments

      Map<String,String> getAttachments()
      get attachments.
      Returns:
      attachments.
    • getObjectAttachments

      Map<String,Object> getObjectAttachments()
      get attachments.
      Returns:
      attachments.
    • addAttachments

      void addAttachments(Map<String,String> map)
      Add the specified map to existing attachments in this instance.
      Parameters:
      map -
    • addObjectAttachments

      void addObjectAttachments(Map<String,Object> map)
      Add the specified map to existing attachments in this instance.
      Parameters:
      map -
    • setAttachments

      void setAttachments(Map<String,String> map)
      Replace the existing attachments with the specified param.
      Parameters:
      map -
    • setObjectAttachments

      void setObjectAttachments(Map<String,Object> map)
      Replace the existing attachments with the specified param.
      Parameters:
      map -
    • getAttachment

      String getAttachment(String key)
      get attachment by key.
      Returns:
      attachment value.
    • getObjectAttachment

      Object getObjectAttachment(String key)
      get attachment by key.
      Returns:
      attachment value.
    • getAttachment

      String getAttachment(String key, String defaultValue)
      get attachment by key with default value.
      Returns:
      attachment value.
    • getObjectAttachment

      Object getObjectAttachment(String key, Object defaultValue)
      get attachment by key with default value.
      Returns:
      attachment value.
    • setAttachment

      void setAttachment(String key, String value)
    • setAttachment

      void setAttachment(String key, Object value)
    • setObjectAttachment

      void setObjectAttachment(String key, Object value)
    • whenCompleteWithContext

      Result whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
      Add a callback which can be triggered when the RPC call finishes.

      Just as the method name implies, this method will guarantee the callback being triggered under the same context as when the call was started, see implementation in whenCompleteWithContext(BiConsumer)

      Parameters:
      fn -
      Returns:
    • thenApply

      <U> CompletableFuture<U> thenApply(Function<Result,? extends U> fn)
    • get

      Throws:
      InterruptedException
      ExecutionException
    • get

      Throws:
      InterruptedException
      ExecutionException
      TimeoutException