Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cursoring for queries in vertx-simple-arango-client #4

Open
mgspross opened this issue Aug 25, 2015 · 0 comments
Open

Implement cursoring for queries in vertx-simple-arango-client #4

mgspross opened this issue Aug 25, 2015 · 0 comments

Comments

@mgspross
Copy link
Contributor

Methods in the vertx-simple-arango-client subproject that return query results should handle cursoring, instead of returning a raw SimpleQueryCursorResponse object.

That is, the code should handle the mechanics of Arango HTTP cursors, and hide this from clients.

Here's an example of what the API for this could look like (subject to change obviously):

Example API

// Get a cursor from a method that executes a query
SimpleArangoCusor<JsonObject> jsonOrders = client.db().collection("orders").all();

// Or get a cursor that maps to a specific type by providing a mapping function.
// This example assumes the Order class provides an Order(JsonObject) constructor.
SimpleArangoCursor<Order> orders = client.db().collection("orders").all(Order::new);

// SimpleArangoCursor has a "forEach" method to iterate over all items,
// fetching additional results as needed...
orders.forEach(order -> processOrder(order));

// ...an "onEnd" method to to detect the end of the results...
orders.onEnd(() -> resultHandler.handle(Future.succeededFuture());

// ...and an "onError" to handle errors
orders.onError(t -> resultHandler.handle(Future.failedFuture(t));

// The underlying Arango cursor will be deleted after the last item is 
// processed by a forEach, or after the first exception occurs.
// As a last resort (not to be relied on), the cursor will be deleted
// after a set timeout (20 minutes), which can be changed before calling forEach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant