New option to schedule the Git garbage collection as a background task

For large repositories the Git garbage collection can take a while. This
is especially true if an aggressive garbage collection is performed.

To avoid long running REST requests a new option 'async' is introduced,
which allows to schedule the garbage collection as a background task.

In case of asynchrouns execution 202 Accepted is returned with the
'Location' header referring to the scheduled background task.

Change-Id: I8b2e63f48d600e6faa3b8cabc135ef0cd6315d64
This commit is contained in:
Adrian Görler
2015-11-03 16:20:56 +01:00
committed by David Pursehouse
parent e0214a1b96
commit 92410a1cfe
4 changed files with 130 additions and 10 deletions

View File

@@ -36,6 +36,11 @@ public abstract class Response<T> {
return new Impl<>(201, value);
}
/** HTTP 202 Accepted: accepted as background task. */
public static Accepted accepted(String location) {
return new Accepted(location);
}
/** HTTP 204 No Content: typically used when the resource is deleted. */
@SuppressWarnings("unchecked")
public static <T> Response<T> none() {
@@ -168,4 +173,33 @@ public abstract class Response<T> {
return String.format("[302 Redirect] %s", location);
}
}
/** Accepted as task for asynchronous execution. */
public static final class Accepted {
private final String location;
private Accepted(String url) {
this.location = url;
}
public String location() {
return location;
}
@Override
public int hashCode() {
return location.hashCode();
}
@Override
public boolean equals(Object o) {
return o instanceof Accepted
&& ((Accepted) o).location.equals(location);
}
@Override
public String toString() {
return String.format("[202 Accepted] %s", location);
}
}
}