quinchs / EdgeDB.Net

C# edgedb client
Apache License 2.0
45 stars 3 forks source link

Official client release #30

Open quinchs opened 1 year ago

quinchs commented 1 year ago

Summary

This PR contains modifications to the dotnet driver API to standardize it with other drivers and changes related to feedback provided by the EdgeDB team.

Changes

State (config, aliases, module, globals)

The state API has changed to follow the other drivers (js/ts, python, go, rust) and is defined like so:

var baseClient = new EdgeDBClient();
var client = baseClient
    .WithConfig(conf => conf.AllowDMLInFunctions = true)
    .WithGlobals(new Dictionary<string, object?>
    {
        { "current_user_id", Guid.NewGuid() }
    });

There are now 4 methods exposed on EdgeDBClient called WithConfig, WithGlobals, WithModule, and WithAliases which will return a new EdgeDBClient that shares the same client pool as its parent (baseClient in this example)[^1].

Object Deserialization

The deserialization step has been optimized to remove the intermediate dynamic object in favor for a ObjectEnumerator type which acts like an IEnumerator. The new method is designed to be fast and play well with the current binary workflow.

Benchmarks

Deserializing the type Person

public class Person
{
    public string? Name { get; set; }

    public string? Email { get; set; }
}
Method Mean Error StdDev Gen 0 Allocated
DeserializePersonOld 1.645 us 0.0311 us 0.0291 us 0.1259 792 B
DeserializePersonNew 487.8 ns 5.28 ns 4.94 ns 0.0505 320 B

TODO's


Node The official release is just for the EdgeDB.Net.Driver package, the query builder is still in development

[^1]: see the js implementation.