Git Product home page Git Product logo

Comments (5)

jdiazcano avatar jdiazcano commented on June 11, 2024

If it worked in 0.9.3 then it seems definitely a bug which I'll take a look tomorrow.

But! I would say that it is a weird way of using the library, what would be the end result that you would like to get?

I would so something like:

interface Database {
    fun username(): String = ""
    fun password(): String = ""    
}

main() {
    val loader = ...
    val provider = ...
    val db = provider.bind<Database>("db")
    assert db.username() == "foo"
}

from cfg4k.

jdiazcano avatar jdiazcano commented on June 11, 2024

Now that I take a second look:

        val url = Property("db.conn", "")
        val connectionTimeout = Property("db.conn.timeout.sec", TimeUnit.SECONDS.toMillis(30))

The bug is happening because you have "db.conn" and "db.conn.timeout.sec" and how it works is by splitting by dot and keep finding the child until it arrives to the latest one. BUT! here you have db.conn that has a value and children at the same time, something that isn't supported.

It might just work if you use the url as db.conn.url.

from cfg4k.

credmond-git avatar credmond-git commented on June 11, 2024

Thanks for looking into it.
I have been treating the library as a key value store. I haven't been using the bind at all.
I have been exclusively using
configProvider.get(key,javaClass, default)
I haven't had any major structure on my keys, they are more names, so they may violate some expectations the library has.

I can change it to db.conn.url and i agree that it should fix the issue. But the behavior has changed since 0.9.3 (maybe it was a bug fix and maybe i am not using the library as you intend). It is your library and if this is the intended use, then i can close my bug.

I will look into using the library properly :)

from cfg4k.

jdiazcano avatar jdiazcano commented on June 11, 2024

Yeah, the library doesn't get along well with not having a proper structure. I'll look more into it anyways and I might even try to make it work somehow. For example cresting a brand new config loader that doesn't look by the dots and saves everything flattened. The problem with that would be when using it with a provider and binding, the rest should all work properly.

It is my library but it is open source, this means everyone has a voice! Don't close it yet as I would like to investigate a little bit more.

This changed in 0.9.4 where the environment config loader uses the same loading strategy as everything else so it works with binding properly.

from cfg4k.

credmond-git avatar credmond-git commented on June 11, 2024

Thanks I appreciate the effort and dedication that must be involved in writing and maintaining an open source library.

from cfg4k.

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.