aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java
new file mode 100644
index 00000000000..fa1660d99e6
--- /dev/null
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/Throttler.java
@@ -0,0 +1,33 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.feed.client;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Determines the number of requests to have inflight at any point.
+ *
+ * @author jonmv
+ */
+interface Throttler {
+
+ /**
+ * A request was just sent with {@code vessel}, with {@code inflight} total in flight.
+ */
+ void sent(long inflight, CompletableFuture<HttpResponse> vessel);
+
+ /**
+ * A successful response was obtained.
+ */
+ void success();
+
+ /**
+ * A throttle signal was obtained from the server.
+ */
+ void throttled(long inflight);
+
+ /**
+ * The target inflight operations right now.
+ */
+ long targetInflight();
+
+}