Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add docs to explain the caveats of using TimingOutQuery.

  • Loading branch information...
commit f1699f84c68a76889cca5514d258241dff68f260 1 parent 96f0ba9
jsirois authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 src/main/scala/com/twitter/querulous/query/TimingOutQuery.scala
View
22 src/main/scala/com/twitter/querulous/query/TimingOutQuery.scala
@@ -6,12 +6,27 @@ import com.twitter.xrayspecs.Duration
class SqlQueryTimeoutException extends SQLException("Query timeout")
+/**
+ * A {@code QueryFactory} that creates {@link Query}s that execute subject to a {@code timeout}. An
+ * attempt to {@link Query#cancel} the query is made if the timeout expires.
+ *
+ * <p>Note that queries timing out promptly is based upon {@link java.sql.Statement#cancel} working
+ * and executing promptly for the JDBC driver in use.
+ */
class TimingOutQueryFactory(queryFactory: QueryFactory, timeout: Duration) extends QueryFactory {
def apply(connection: Connection, query: String, params: Any*) = {
new TimingOutQuery(queryFactory(connection, query, params: _*), timeout)
}
}
+/**
+ * A {@code QueryFactory} that creates {@link Query}s that execute subject to the {@code timeouts}
+ * specified for individual queries. An attempt to {@link Query#cancel} a query is made if the
+ * timeout expires.
+ *
+ * <p>Note that queries timing out promptly is based upon {@link java.sql.Statement#cancel} working
+ * and executing promptly for the JDBC driver in use.
+ */
class PerQueryTimingOutQueryFactory(queryFactory: QueryFactory, timeouts: Map[String, Duration])
extends QueryFactory {
@@ -20,6 +35,13 @@ class PerQueryTimingOutQueryFactory(queryFactory: QueryFactory, timeouts: Map[St
}
}
+/**
+ * A {@code Query} that executes subject to the {@code timeout} specified. An attempt to
+ * {@link #cancel} the query is made if the timeout expires before the query completes.
+ *
+ * <p>Note that the query timing out promptly is based upon {@link java.sql.Statement#cancel}
+ * working and executing promptly for the JDBC driver in use.
+ */
class TimingOutQuery(query: Query, timeout: Duration) extends QueryProxy(query) {
override def delegate[A](f: => A) = {
try {
Please sign in to comment.
Something went wrong with that request. Please try again.