Class DataRequest

java.lang.Object
net.swofty.redisapi.api.requests.DataRequest

public class DataRequest extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The internal channel every request and response travels over.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataRequest(String filterID, String key, @Nullable org.json.JSONObject data)
    Create a new data request to get a specific object of data from a specific server.
  • Method Summary

    Modifier and Type
    Method
    Description
    Publishes the request and returns a future that completes the moment a response arrives (or after 1000Lms with a null response, same as before) - without ever blocking or parking a thread while waiting.
    static void
    receive(String id, org.json.JSONObject response)
    Called by whatever listens for incoming Redis messages when a RESPONSE-stream message with a matching id comes back.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DataRequest

      public DataRequest(String filterID, String key, @Nullable @Nullable org.json.JSONObject data)
      Create a new data request to get a specific object of data from a specific server.
      Parameters:
      filterID - the destination of the request. Can be "all" for all listeners.
      key - a unique key for the data request.
      data - optional request payload, may be null for an empty payload.
  • Method Details

    • await

      Publishes the request and returns a future that completes the moment a response arrives (or after 1000Lms with a null response, same as before) - without ever blocking or parking a thread while waiting. The future is fulfilled by receive(String, JSONObject) when the corresponding DataRequestResponder response comes back over Redis.
      Returns:
      a DataResponse which must be handled in async.
    • receive

      public static void receive(String id, org.json.JSONObject response)
      Called by whatever listens for incoming Redis messages when a RESPONSE-stream message with a matching id comes back. This is the only thing that completes a pending future - replaces the old pattern of putting straight into a shared map and having callers poll it.
      Parameters:
      id - the request id this response is answering.
      response - the response payload.