GithubHelp home page GithubHelp logo

hannahwhy / analysand Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 176 KB

a CouchDB client library of dubious worth (mirror)

Home Page: https://gitlab.peach-bun.com/yipdw/analysand

License: MIT License

Ruby 100.00%

analysand's Introduction

open issues: uncountable

analysand's People

Contributors

hannahwhy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dpla-attic

analysand's Issues

ChangeWatcher's connection-checking mechanism needs to be able to use credentials

A CouchDB database that has a nonempty member list will restrict access to its change feeds. ChangeWatcher needs to be able to deal with this scenario.

At present, ChangeWatcher treats 4xx errors as connection errors. That's fine, but we should be able to apply the same request-customization code to connection checking.

Stream views

CouchDB views may contain a great many documents. At present, Analysand parses the entire JSON stream and only presents the completed object. This won't work for e.g. _all_docs or large view ranges.

I'd like to write it like this:

resp = db.view('video/by_editor_and_title', :startkey => ['foo', 'bar'], :endkey => ['baz', 'xyz']) do |view, row|
  view.total_rows # total number of rows
  view.offset # => the offset
  row # => { "id": "doc_id", "key": ["foo", "bar"], "value": { ... } }, etc.  basically, the current row
  break # to abort streaming
end

resp.success? # => true or false
resp.offset # => the offset
resp.total_rows # => total number of rows
resp.rows # raises NoMethodError: a streaming response doesn't respond to this; rows aren't kept around

db.all_docs do |view, row|
  # same idea
end

YAJL can be used for this -- it is capable of streaming individual elements in a JSON array -- but the yajl-ruby gem, as far as I can tell, buffers incoming data until a complete JSON object is constructed. (It's possible to stream multiple JSON objects over the wire, which is what Analysand::ChangeWatcher needs to work with, but not to receive e.g. rows in an array as they're built.)

Analysand::Http::_req does not escape document IDs clearly

I'm running into an issue where a partner's database has keys that look like 10067--http://ark.cdlib.org/ark:/13030/kt067nc38g. The docs for Analysand::Database note the following:

  # Note: CouchDB treats forward slashes (/) specially.  For document IDs, /
  # denotes a separator between document ID and the name of an attachment.
  # This library makes use of that to implement attachment storage and
  # retrieval (see below).
  #
  # If you are using forward slashes in document IDs, you MUST encode them
  # (i.e. replace / with %2F).

In my case, I've made sure that I've escaped the IDs (using CGI.escape), before they even get passed to Analysand::Http::_req. This ensures an ID like 10067--http%3A%2F%2Fark.cdlib.org%2Fark%3A%2F13030%2Fkt067nc38g gets passed to Analysand::Http::_req.

However, given that % is a reserved character in URIs, it gets escaped again (when Analysand::Http::_req calls URI.escape, which means the actual document ID that gets requested is 10067--http%253A%252F%252Fark.cdlib.org%252Fark%253A%252F13030%252Fkt067nc38g. (In other words, the % characters get double-escaped.)

Make it easier to use cookies from CouchDB requests to prolong sessions

When using CouchDB with session cookies, renewed session cookies may be issued by CouchDB if the supplied session cookie meets a number of criteria.

One such criterion in CouchDB 1.2.0: A new cookie will be issued if the supplied cookie is not expired and was issued within 10% of the timeout window. Example: if the timeout window is 600 seconds, and the cookie was issued later than .1 * 600 = 60 seconds ago, a new cookie will be issued.

Analysand's present methods return a response from CouchDB, but they do not yet provide any way of accessing a renewed session cookie. Add one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.