ReactiveCouchbase / ReactiveCouchbase-core

Core library for ReactiveCouchbase
Apache License 2.0
64 stars 28 forks source link

Authorization Headers with Expiremental View Queries #48

Open zbintliff opened 9 years ago

zbintliff commented 9 years ago

We are working on experiemental view queries, and adding Authorization Headers to it. Something like this:

    if (bucket.user != null) {
      bucket.httpClient.prepareGet(url).addHeader("Authorization", HttpUtil.buildAuthHeader(bucket.user, bucket.pass)).execute(responseHandler)
      promise.future.map(body => (Json.parse(body) \ "rows").as[JsArray])
    } else {
      bucket.httpClient.prepareGet(url).execute(responseHandler)
      promise.future.map(body => (Json.parse(body) \ "rows").as[JsArray])
    }

That would be in __internalViewQuery() in the org.reactivecouchbase.experimental.ViewRow.scala.

We also are implementing a sort of round robin, so it will rotate which node queries like so:

var nodeToQuery = bucket.hosts.toArray.apply(counter % bucket.hosts.size)
counter += 1  //counter is a global variable

Let me know if you are interested in pulling down any of these. We are in the process of testing these out.