Giter VIP home page Giter VIP logo

Comments (4)

erdeszt avatar erdeszt commented on August 15, 2024

I've looked into updating doobie to 1.0.0-RC4 and have a branch where things compile BUT: the KleisliInterpreter now requires a LogHandler instance as a parameter which poses a challenge. I have a few ideas how to solve this but none of them are ideal:

  • Just use LogHandler.noop => this is bad because query logging will be disabled which would break peoples expectations at runtime
  • Update the api to take a LogHandler in connectionFromJdbc (and fromConnectionSource) => this is bad for multiple reasons. It's a breaking change and more importantly it would leak doobie specific details into the api (and would make this PR impossible: #45)
  • Update io.github.gaelrenoux.tranzactio.doobie.Database to be a class that takes a LogHandler instance in the constructor => this is a breaking api change but it's the most flexible solution I can think of
  • Create a custom LogHandler instance inside io.github.gaelrenoux.tranzactio.doobie.Database => this is bad because it would remove the option of customizing the LogHandler by users of this library but this is the least intrusive change(other than using LogHandler.noop) and might be a good temporary solution until the final doobie-1.0.0 is released(because things might change again while it's in RC).

What do you think @gaelrenoux ? I'd be happy to submit a PR if we can agree on a direction to take.

from tranzactio.

hmemcpy avatar hmemcpy commented on August 15, 2024

I just encountered this. We needed to upgrade doobie for effectful logging. @gaelrenoux, is there anything you need to move this forward? Would be happy to send a PR (if @erdeszt doesn't beat me to it first :))

from tranzactio.

gaelrenoux avatar gaelrenoux commented on August 15, 2024

A custom LogHandler is indeed the easiest solution. Honestly I think I'd use the noop in that case, rather that force logging of queries through a custom-built LogHandler instance: it's not perfect, but there are other ways to see the queries being executed, and forcing the logs would have performance implications. Obviously, that's still not a very good solution.

Changing the Database to to take a LogHandler instance on creation: I don't think that would work. All the layer-building methods (such as DatabaseModuleBase.fromDatasourceAndErrorStrategies`) wouldn't work without passing the LogHandler, which would again require changing the general API.

The best idea I can think of is to introduce a general Context trait, passed on creation, which would have a different implementation based on which library you are using. The Doobie implementation of Context would contain the LogHandler. This would also be a more flexible solution, that will allow other library-specific information to be carried when necessary. I'll try and see what I can do.

from tranzactio.

gaelrenoux avatar gaelrenoux commented on August 15, 2024

I've created PR #48 for this topic. I'd gladly have one of you guys review it, see what you think.

from tranzactio.

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.