1.5.0-alpha01
Pre-releaseAsynchronous API is available from this release!
Async API is one of the main focuses in 1.5 .NET driver releases. In the first alpha release of this 1.5 series, we would like to represent a new asynchronous API, as well as full stack async support for direct driver, which is the driver connects to a specific server and does not support casual-cluster routing & load balancing.
The async API looks very similar to our existing synchronous API. The code bellow shows a simple example of how to code using the new async API:
public async Task PrintGreetingAsync(string message)
{
var driver = var driver = GraphDatabase.Driver("bolt://127.0.0.1", AuthTokens.Basic(user, password),
new Config
{
EncryptionLevel = EncryptionLevel.Encrypted,
MaxIdleConnectionPoolSize = 20,
MaxConnectionPoolSize = 50,
ConnectionAcquisitionTimeout = TimeSpan.FromMinutes(2)
});
var session = driver.Session();
try
{
var greeting = await session.WriteTransactionAsync(async tx =>
{
var result = await tx.RunAsync("CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)", new {message});
if (await result.ReadAsync())
{
return result.Current()[0].As<string>();
}
else
{
return null;
}
});
Console.WriteLine(greeting);
}
finally
{
await session.CloseAsync();
}
driver.Close();
}
You are most welcome to try out this alpha and give us your valuable feedback (via such as gitHub issues).
The alpha artifact could be found available in Nuget and can be installed by using Install-Package Neo4j.Driver -Pre
Async support for routing driver (a.k.a. the driver for connecting to a cluster with built-in routing and load balancing) and docs are coming soon!