c# - RavenDB, programmatically check whether Server instance is running -



c# - RavenDB, programmatically check whether Server instance is running -

i configure document store in next way:

store = new documentstore { url = serverurl }; store.initialize();

i know how can create sure prior or post initialization but before opening session whether client connected server. did not startup server , still initialize store, not sure why or whether creates default embedded db if cannot find server under specified url. thought how check connection established between client , server?

initialization not open connection. ravendb client opens , closes connections needs to.

it not revert embedded database. have explicitly utilize embeddabledocumentstore if want embedded database instance.

if want check if server up, can , see if fails. easiest thing seek build number of ravendb server. can done using documentstore.asyncdatabasecommands.getbuildnumberasync().

here extension methods help create easier. set these in static class:

public static bool trygetserverversion(this idocumentstore documentstore, out buildnumber buildnumber, int timeoutmilliseconds = 5000) { seek { var task = documentstore.asyncdatabasecommands.getbuildnumberasync(); var success = task.wait(timeoutmilliseconds); buildnumber = task.result; homecoming success; } grab { buildnumber = null; homecoming false; } } public static bool isserveronline(this idocumentstore documentstore, int timeoutmilliseconds = 5000) { buildnumber buildnumber; homecoming documentstore.trygetserverversion(out buildnumber, timeoutmilliseconds); }

then can utilize them this:

var online = documentstore.isserveronline();

or this:

buildnumber buildnumber; var online = documentstore.trygetserverversion(out buildnumber);

c# ravendb ravendb-http

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -