Get database name changes by MyCouch

276 Views Asked by At

I need the database names and their changes in my app.

This is my code:

var cancellation = new CancellationTokenSource().Token;

var cnInfo = MyCouch.DbConnectionInfo(serverUrl, "_all_dbs");

cnInfo.BasicAuth = authString;

cnInfo.Timeout = TimeSpan.FromMilliseconds(System.Threading.Timeout.Infinite);

var db = new MyCouch.MyCouchClient(cnInfo);
var changes = db.Changes.ObserveContinuous(MyCouch.Requests.GetChangesRequest
               (
                   Feed = MyCouch.ChangesFeed.Continuous,
                   Since = "0",
                   Heartbeat = 999999999, 
                   IncludeDocs = true,
                   Style = MyCouch.ChangesStyle.MainOnly
               ), cancellation).Take(1).Wait();

The first attempt after several minutes returns the database names, but it blocks on next attempts. I can get the database names by getting http://localhost:5984/_all_dbs.

I'm pretty sure that I have some databases on the server.

Update : Subscription to the changes works :

db.Changes.ObserveContinuous(MyCouch.Requests.GetChangesRequest
               (
                   Feed = MyCouch.ChangesFeed.Continuous,
                   Since = "0",
                   Heartbeat = 999999999, 
                   IncludeDocs = true,
                   Style = MyCouch.ChangesStyle.MainOnly
               ), cancellation).Subscribe(print); //=> the print works.

The main problem seems to be .Take(1).Wait(). I expect the .Take(1) append an .OnCompleted() to the observable, but it doesn't seem to. Any suggestions?

0

There are 0 best solutions below