Code Monkey home page Code Monkey logo

Comments (4)

mfenniak avatar mfenniak commented on August 15, 2024

Hey @nkreipke.

I think this sounds like a great idea. I'm not too familiar with all the new .NET API levels, but it sounds like it would be really valuable for non-standard platforms to be able to access RethinkDB.

I would suggest that where possible, it's probably better to use supplemental assemblies rather than conditional compilation. In my experience, conditional compilation is annoying to maintain over time. For example, it'd be preferable to have a .NET 4.5 assembly that provides the System.Configuration capabilities (eg. rethinkdb-net-netconfig?), rather than having it conditionally compiled in one central assembly.

When it's ready, and it has at least a good upgrade path for current users, I'd be happy to review and merge a PR. Let me know how else I can help out; I don't have a lot of spare time, but I'd sure like to do anything I can to encourage a new contributor. :-)

from rethinkdb-net.

nkreipke avatar nkreipke commented on August 15, 2024

I've now moved the System.Configuration part to a separate rethinkdb-net-appconfig project and replaced the ConfigurationAssembler class with a more flexible ConnectionFactoryBuilder. You could now create a connection factory like this:

var factory = new ConnectionFactoryBuilder().FromAppConfiguration().Build("testCluster");

One issue I found with a separate appconfig assembly is that users will have to adjust the section configuration in addition to installing a new package:

<section name="rethinkdb" type="RethinkDb.AppConfig.RethinkDbClientSection, RethinkDb.AppConfig"/>

I've left a deprecation notice in ConfigurationAssembler that notifies users of the changes, however requiring users to change their configuration might cause inconvenience. We might be able to blame Microsoft and their ridiculous System.Configuration architecture for this ;-)

Apart from that, I removed the JSON configuration as we already provide an interface to Microsoft.Extensions.Configuration, which allows loading all sorts of configuration formats. Reading a JSON file would be relatively easy (probably even easier in ASP.NET Core as they're using DI for this):

var config = new ConfigurationBuilder().AddJsonFile("rethinkdb.json").Build();
var factory = new ConnectionFactoryBuilder().FromConfiguration(config).Build("testCluster");

You could also build a connection factory directly with a ClusterElement class.

While porting RethinkDb.Newtonsoft I found some duplicated code where the connection factory is created, but the builder class solves the problem quite elegantly:

var factory = new ConnectionFactoryBuilder()
    .FromAppConfiguration()
    .UseNewtonsoftJsonSerializer()
    .Build("testCluster");

I think all that's left to do for now is updating the examples and documentation. Just wanted to ask if you're OK with these changes :-)

from rethinkdb-net.

mfenniak avatar mfenniak commented on August 15, 2024

The builder approach sounds great to me. I like the implementation of UseNewtonsoftJsonSerializer as an extension method on the builder; that approach seems really easy to use while still being very flexible to additional extensions in the future.

A little unfortunate that the config file namespace changes, but, I think that's pretty easy to document and not a very onerous change for people to make.

from rethinkdb-net.

bchavez avatar bchavez commented on August 15, 2024

FWIW, you can also use this bchavez/C# driver with RethinkDB which already supports .NET Core and net45. However, bchavez/C# driver follows more closely the design of the official drivers & official documentation meaning you'll need to use ReQL in C#.

from rethinkdb-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.