Skip to content

Commit

Permalink
API cleanup for Async Volley stack ahead of 1.2.0 release. (#398)
Browse files Browse the repository at this point in the history
- Add warning to new APIs noting that they are experimental and subject to change
- Mark NetworkUtility as package-private since it should not be used externally
  (all methods were already package-private)

This unblocks a 1.2.0 release while permitting us to refine the API further
before we lock it down in a similar way to other Volley APIs.

See #181
  • Loading branch information
jpd236 authored Feb 17, 2021
1 parent 03f0144 commit 36274bf
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/main/java/com/android/volley/AsyncCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@

import androidx.annotation.Nullable;

/** Asynchronous equivalent to the {@link Cache} interface. */
/**
* Asynchronous equivalent to the {@link Cache} interface.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public abstract class AsyncCache {

public interface OnGetCompleteCallback {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/android/volley/AsyncNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference;

/** An asynchronous implementation of {@link Network} to perform requests. */
/**
* An asynchronous implementation of {@link Network} to perform requests.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public abstract class AsyncNetwork implements Network {
private ExecutorService mBlockingExecutor;
private ExecutorService mNonBlockingExecutor;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/android/volley/AsyncRequestQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
* An asynchronous request dispatch queue.
*
* <p>Add requests to the queue with {@link #add(Request)}. Once completed, responses will be
* delivered on the main thread (unless a custom {@link ResponseDelivery} has been provided)
* delivered on the main thread (unless a custom {@link ResponseDelivery} has been provided).
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public class AsyncRequestQueue extends RequestQueue {
/** Default number of blocking threads to start. */
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/android/volley/RequestTask.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.android.volley;

/** Abstract runnable that's a task to be completed by the RequestQueue. */
/**
* Abstract runnable that's a task to be completed by the RequestQueue.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public abstract class RequestTask<T> implements Runnable {
final Request<T> mRequest;

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/android/volley/cronet/CronetHttpStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@

/**
* A {@link AsyncHttpStack} that's based on Cronet's fully asynchronous API for network requests.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public class CronetHttpStack extends AsyncHttpStack {

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/android/volley/toolbox/AsyncHttpStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;

/** Asynchronous extension of the {@link BaseHttpStack} class. */
/**
* Asynchronous extension of the {@link BaseHttpStack} class.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public abstract class AsyncHttpStack extends BaseHttpStack {
private ExecutorService mBlockingExecutor;
private ExecutorService mNonBlockingExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
import java.util.Map;
import java.util.concurrent.ExecutorService;

/** A network performing Volley requests over an {@link HttpStack}. */
/**
* A network performing Volley requests over an {@link HttpStack}.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public class BasicAsyncNetwork extends AsyncNetwork {

private final AsyncHttpStack mAsyncStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Utility class for methods that are shared between {@link BasicNetwork} and {@link
* BasicAsyncNetwork}
*/
public final class NetworkUtility {
final class NetworkUtility {
private static final int SLOW_REQUEST_THRESHOLD_MS = 3000;

private NetworkUtility() {}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/android/volley/toolbox/NoAsyncCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import com.android.volley.AsyncCache;
import com.android.volley.Cache;

/** An AsyncCache that doesn't cache anything. */
/**
* An AsyncCache that doesn't cache anything.
*
* <p><b>WARNING</b>: This API is experimental and subject to breaking changes. Please see
* https://github.com/google/volley/wiki/Asynchronous-Volley for more details.
*/
public class NoAsyncCache extends AsyncCache {
@Override
public void get(String key, OnGetCompleteCallback callback) {
Expand Down

2 comments on commit 36274bf

@paulsmithkc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a tutorial available on how to use this AsyncCache?

@jpd236
Copy link
Collaborator Author

@jpd236 jpd236 commented on 36274bf Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, no, because we haven't yet provided a reference implementation for the interface. For now, the recommendation (per https://github.com/google/volley/wiki/Asynchronous-Volley#code) is to just use a regular Cache/DiskBasedCache. Cache operations will be performed using the blocking thread pool.

Please sign in to comment.