diff options
author | Azul <azul@riseup.net> | 2016-06-08 12:44:38 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-06-08 12:54:23 +0200 |
commit | a89e2ba55399e6bddd9e052cf2064ed0056c958a (patch) | |
tree | c28ec332f9763f395a88db991defcae59fa46806 /lib/nickserver/couch_db | |
parent | 712c1d062c08a58ca8772aafcdc39d0281959b4a (diff) |
refactor: use new couch_db classes from fetch_key
This moves all the em_http related stuff into a single adapter.
We're also not using callback and errback inside fetch_key or
server for couch requests anymore.
Changing the interface for hkp to do the same will follow.
Diffstat (limited to 'lib/nickserver/couch_db')
-rw-r--r-- | lib/nickserver/couch_db/source.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/nickserver/couch_db/source.rb b/lib/nickserver/couch_db/source.rb index fffa76e..874fe4f 100644 --- a/lib/nickserver/couch_db/source.rb +++ b/lib/nickserver/couch_db/source.rb @@ -2,6 +2,7 @@ # This class allows querying couch for public keys. # require 'nickserver/couch_db/response' +require 'nickserver/config' module Nickserver::CouchDB class Source @@ -13,13 +14,17 @@ module Nickserver::CouchDB end def query(nick) - adapter.get VIEW, query: query_for(nick) do |status, body| - yield Response.new nick, status: status, body: body + adapter.get url, query: query_for(nick) do |status, body| + yield Response.new(nick, status: status, body: body) end end protected + def url + Nickserver::Config.couch_url + VIEW + end + def query_for(nick) { reduce: "false", key: "\"#{nick}\"" } end |