Hi, I just wanted to check if someone more knowledgeable in HTTP.jl could help me out with fixing another package that is a bit older and not entirely updated to recent HTTP.jl?
Couchzilla.jl is a julia interface to couchDB.
I get most things to work but there’s a function in the replication.jl file that listens for changes in the database.
function changes_streaming(db::Database;
doc_ids = [],
conflicts = false,
descending = false,
include_docs = false,
attachments = false,
att_encoding_info = false,
limit = 0,
since = 0)
query = opts(conflicts=conflicts, descending=descending, include_docs=include_docs,
attachments=attachments, att_encoding_info=att_encoding_info, limit=limit,
since=since, feed="continuous", timeout=0)
body = Dict{Any, Any}()
headers = Dict("Content-Type" => "application/json")
method = HTTP.get
if length(doc_ids) > 0
query["filter"] = "_doc_ids"
body = Dict("doc_ids" => doc_ids)
method = HTTP.post
end
stream = method(endpoint(db.url, "_changes"), headers, JSON.json(body); cookies=db.client.cookies, query=query)
function producer(chan::Channel)
while true
line = strip(readline(stream))
if length(line) > 0 && line[1] == '{'
put!(chan, JSON.parse(line))
end
if eof(stream)
break
end
end
end
end
As far as I can understand it returns a function which one can use to listen to. According to the docs this is then how to use it:
for ch in Channel(changes_streaming(db; limit=1))
count += 1
end
I do however, get an error that reads:
nested task error: MethodError: no method matching readline(::HTTP.Messages.Response)
Closest candidates are:
readline() at io.jl:506
readline(::AbstractString; keep) at io.jl:500
readline(::IOStream; keep) at iostream.jl:444
...
Stacktrace:
[1] (::Couchzilla.var"#producer#23"{HTTP.Messages.Response})(chan::Channel{Any})
@ Couchzilla ~/.julia/packages/Couchzilla/tKI4Y/src/replication.jl:105
[2] (::Base.var"#519#520"{Couchzilla.var"#producer#23"{HTTP.Messages.Response}, Channel{Any}})()
@ Base ./channels.jl:132
My guess something has changed in HTTP such that the old function in Couchzilla doesn’t produce an IOStream.
Does anyone see a solution on what I need to change?
the code is found here: couchzilla.jl