The type EmbeddableDocumentStore is gone. But it does not mean that you have no good options to replace his functionality. The technique I share here can be easily adopted in any language or framework.

Are you ready? So, let’s examine the Raven.TestDriver source code.

private static ProcessStartInfo GetProcessStartInfo(TLocator locator)
{
    if (File.Exists(locator.ServerPath) == false)
    {
        throw new FileNotFoundException("Server file was not found", locator.ServerPath);
    }

    using (var currentProcess = Process.GetCurrentProcess())
    {
        var commandArguments = new List
        {
            locator.CommandArguments,
            "--ServerUrl=http://127.0.0.1:0",
            "--RunInMemory=true",
            "--Testing.ParentProcessId=" + currentProcess.Id,
            "--Setup.Mode=None"
        };

        var argumentsString = string.Join(" ", commandArguments);
        return new ProcessStartInfo
        {
            FileName = locator.Command,
            Arguments = argumentsString,
            CreateNoWindow = true,
            RedirectStandardOutput = true,
            RedirectStandardError = true,
            UseShellExecute = false,
        };
    }
}

Yeap! You got it. Our recommendation now is to start a child process instead of having Raven running on the same process of your application.

As you can see, you can now specify a “Parent Process Id” to the RavenDB Server. So, when the “parent process” is gone, Raven will gently stop as well.

Please, note the “RunInMemory” option. Nice, huh?

Let me know if you have any additional questions about this subjects.

More posts in "Let me help you to start using RavenDB4" series:

Leave a Reply

Your email address will not be published. Required fields are marked *