Class DataRequest
java.lang.Object
net.swofty.redisapi.api.requests.DataRequest
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDataRequest(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 TypeMethodDescriptionawait()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 voidCalled by whatever listens for incoming Redis messages when aRESPONSE-stream message with a matching id comes back.
-
Field Details
-
CHANNEL
The internal channel every request and response travels over. Registered automatically byRedisAPI.startListeners().- See Also:
-
-
Constructor Details
-
DataRequest
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 byreceive(String, JSONObject)when the correspondingDataRequestResponderresponse comes back over Redis.- Returns:
- a
DataResponsewhich must be handled in async.
-
receive
Called by whatever listens for incoming Redis messages when aRESPONSE-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.
-