-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add URI Loader SPI #176
base: master
Are you sure you want to change the base?
Add URI Loader SPI #176
Conversation
Let me follow up and inspect more on Monday. It is looking good though! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just minor critiques otherwise looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of my critique is debatable so I'll let you or Rob decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good enough to be pushed into master for me provided #177 changes get in first.
avaje-config/src/main/java/io/avaje/config/ConfigServiceLoader.java
Outdated
Show resolved
Hide resolved
Hmmm, not enthused by this PR. Let's start from the very top with the motivation. What are some actual examples of a URIConfigLoader? I've seen some things like |
I talk about some of the URI we use here : #175 (comment) ultimately it is going to depend how opinionated you want to keep ajave. The initial loading of avaje can all be expressed in URI. We do special loading:
In our config framework only one classpath resource is loaded and all that other shit is URIs for load.properties this includes cloud resources and k8s. I’ll add more tomorrow. |
Thanks. Yeah, I'm wanting to know the specific things that we are trying to add here. It isn't clear to me if we are looking to do some existing stuff (env vars, system properties, profiles) differently. For example already have |
I just showed how no one needs to know anything about them. They are internal. I mean you can switch it to: _sentry_man_does_not_like_required=true Only the As for Load Flags it is only because it was effective to serialize and represent lots of booleans. Regardless we need to represent NOT_REQUIRED somehow unless we always have optional load. Here are our choices some overlap:
|
Also besides required what if wanted to load a resources with out interpolation.... let it sit in that passwords might contain I had checked in we had use LoadFlag.NO_INTERPOLATION for that exact reason in some CLI too. stdin://client_password?_loadFlag=no_interpolation You see that is why there are so many load flags. Overtime we just kept needing more behavior. This internal library is 13+ years old. The world has changed quite a bit . I had the logic at first in the URI loaders and it was painful. Adding flags was so much easier than the alternatives. All the loaders would get that extra capabilities for free. |
I'll probably get it when we start implementing |
@SentryMan @rbygrave I'm in the process of opensourcing my companies kvs config library. By doing so I'm ripping out legacy stuff, documenting, and trying to find what is best including ripping out the scary LoadFlags. I don't plan on publishing it to maven central and would prefer to make avaje-config work but since I have the code I might as well publish it for looking over. It has very little javadoc which I'm fixing in the next few weeks. My hope is you can pull out the best parts of it you like. However I think what @SentryMan has already done is pretty good. Possibly even good enough with the exception of require/optional lacking. That isn't really that much a problem because one could always make their own URIConfigLoader to forcefully require it (or make it optional). There are some API changes I think should be made for the safety of long term unchanging API: I would change: /**
* @param uri uri from which to load data
* @param parsers map of {@link ConfigParser} available to assist in parsing data, keyed by {@link
* ConfigParser#supportedExtensions()}
* @return key/value map of loaded properties
*/
Map<String, String> load(URI uri, URILoadContext ctx); /**
* @param uri uri from which to load data
* @param parsers map of {@link ConfigParser} available to assist in parsing data, keyed by {@link
* ConfigParser#supportedExtensions()}
* @return key/value map of loaded properties
*/
KeyValueSupplier load(URI uri, URILoadContext ctx);
interface KeyValueSupplier {
Iterable<Entry<String,String>> load() throws IOException;
} Also instead of String[] supportedSchemes(); I think boolean supports(URI uri); Then you just loop through with the only special handling of This allows the flexibility of doing something like: myplugin.classpath://blah.properties Then the supports is: boolean supports(URI uri) {
return uri.toString().startsWith("myplugin.");
} (you can always make an abstract class to do the |
This PR isn't close in terms of something we can work off for this issue. It removed the Parsers concept, has changes unrelated to this issue, doesn't keep this change separate enough from existing functionality, plus ultimately I believe the "URI Like" loader distills down to not using the URI type (due to the parameters being provided via the context, and we don't strictly need the prefix, so URI looks to distill down to a path ... but we have modifiers/flags. So no I don't think this PR provides a good base for this change. I'll look to create a new issue that outlines what we have distilled this down to. |
I'm generally in agreement in terms of it actually being pushed into master or at least the hesitation but I'm unclear on the above as I thought parsers were still in? I will say that @SentryMan has been so great and put in good/hard work so that might be what is making me feel like it was good enough. That is if anyone has caused the train to derail a bit I'm entirely to blame.
Yeah that is a great idea as it is getting confusing with the changes in code and comments. Perhaps this time we wait on implementation and get some sort doc on how it works. Also I wasn't sure if it is still helpful for me to continue to pseudo open source my companies config library or do you think that might distract @rbygrave ? I'm still not sold on the URI being not really URI. That was @SentryMan and talked about this format: _someId_load.properties=profiles.classpath://something.properties
_anotherId_load.properties=... But we can talk about that on the new issue. |
I will say that there several actual bugs that need to be fixed or at the minimum the doc adjusted. I was kind of hoping for those before URI. @SentryMan which PR is the recursive loading of
It also shows interpolation in the So on one hand this URI stuff might have been a distraction but on the other I think we found some good issues that could be fixed without breaking things I think. |
yeah #178 is the one |
@SentryMan question did you put in some way to completely disable Avaje Config default loading? I saw a weird boolean somewhere like Because one thought I have so that I can use the You see I'm big on modularity and our system has the loading entirely separate from the fetching of properties. That is the whole https://github.com/agentgt/configfacade The above was my pseudo opensourcing of our What is not opensource @rbygrave is the loading of Key Values (or probably Name Value pair is better since there can be duplicates and it is a list with order). That is in our system we have:
Anyway I do realize there is debt to having more modules but it is just a thought if we do massive changes. |
I added a boolean to disable custom URI loaders, not the built-in ones |
Response to #193
I was thinking of having this new mechanism as a compliment to the existing one. That is, what I would like to see is that we initially continue the standard loading process we have now (achieved with the new loaders):
and then after that, processing the
Do we actually need them?
Should the test loading order not go in the application-test-.properties? Why should this be in the main application.properties? I was thinking we could load test properties after loading app properties. (like we do now) In this way, a user can override the |
It's an option we can look at. We can discuss how we use the new mechanism later once we have a really good idea of how it's going to work [e.g. eval/interpolation impact]. My gut is saying this is can be an alternative that can replace the existing mechanism and that approach will have significant benefits as a "new alternative". ... but yeah, we can go through this again probably when we have a really good feel for the full impact / implications.
We need to be careful, in that if we look closely we see that it's
So that's the thing, today test properties are not loaded absolutely last but instead loaded before the ConfigurationSource. If everything is a "New ConfigLoader2 thing" ... then we have test properties not loaded strictly last. If we search above for "Ordering and test configuration", I discuss the test configuration questions.
For MAYBE / NOT_REQUIRED, I think we do need the flag. It might be via the At this stage, these are the 2 Flags / 2 use cases that we need to support in some way (currently via "Flags"). |
The how is simple (though I'm partial to
how likely is it that an encoded value passed via stdin would have |
I have ported a subset of our configuration framework to OSS. https://github.com/jstachio/kiwi I have made it public. It is obviously lacking javadoc and lots of other stuff. My sole purpose on putting it up is to give you guys ideas and for me to try things. Besides the readme I guess the unit test kind of shows how it works: There are lots of major differences with avaje config but lots of similarities notably the chaining. Right now I'm working on the idea that all resources (URI) aka _load_somename=uri
_flag_somename=flags... Where Furthermore there is none of this of which I disagree with: load.properties=uri_maybe uri_sort_of That is Kiwi pushes hard on the idea of always key values and resources are URI with some name. Now here is the shitty part. The library is already 80kb. Avaje in maven central is like 79kb. |
Just to say, Kiwi - is a Bird, the National symbol of New Zealand, and a nickname for people from New Zealand. |
Yeah the name is a placeholder. In the US Kiwi is fruit from the tree aka kiwifruit. Half our companies business is in APAC and they said the same thing to me but less about the bird and more about NZ (most of our guys are Australian which I think you are as well?). I picked kiwi cause lol I asked ChatGPT to come up with the closest tree like thing that sounded like key value. (btw do you think the name is offensive? If so I will change it immediately.) |
Close but no, I'm a Kiwi :) ... the "Person from New Zealand" variety - not the Fruit :)
No, it's not offensive. New Zealand is a small country, we are used to people not knowing much about us etc. It's a standing joke that as a country we are left off most world maps. No worries there.
That's pretty funny to me in that Kiwifruit grows on a Vine, I wouldn't actually consider it a Tree per se. ChatGPT was a tad "creative" there.
Well, if they are into Cricket they will be loving us Kiwis at the moment [with NZ's wins over India in India - truely epic]. Maybe don't talk about the Rugby though. |
ok but do we actually need this though? For what reason do we need to handle |
@agentgt I lived in San Fransisco for a few years and Boston for a few years, so I do realise just how little Americans know about New Zealand. Given you have released "Kiwi" ... I feel obliged to fill you in a little on New Zealand and Kiwi culture. When you asked if "Kiwi" was offensive I did say that it wasn't offensive and I'd still say that. What I would suggest though, is it "rather uninformed" and being American that is kind of expected per se. Kiwi are important to us and for example, the Kiwi is on our military uniform: The Kiwi is our national bird [like your bald eagle]. New Zealand as a land mass broke off from Gondwana 85 million years ago so we are well known for our unique flora and fauna - the Kiwi is unique to New Zealand and an endangered species [there are only a few places in NZ where you would be able to find and see Kiwi in the wild]. Noting that we have a whole lot of birds and plants that only exist in New Zealand, the "Silver Fern" is a plant only found in NZ and also a national symbol. Kiwis representing New Zealand in sport will either be wearing either the Kiwi or the Silver Fern and typically Black or White uniforms. Culturally we are a mix of indigenous Maori culture, British culture, Polynesian culture and the usual polygot. Respecting culture is kind of big in New Zealand and we are really big into "Haka" as a Welcome, a Celebration, a sign of Respect, or a Challenge - it has many uses. If you are important or cool you'll get a Haka as a welcome e.g. Billie Eilesh - https://www.youtube.com/watch?v=ej_lp0ZwckY ... so yeah Kiwis love a good Haka. Hopefully some of that is interesting. Cheers, |
I'm going to change the name (kiwi). I'm just trying to decide whether I call it kiwifruit and keep the package/module/maven gav as Or just give up the tree err plant thing and go with "ezkv" or "kvs" or [insert name]. @rbygrave Thanks for being patient (EDIT as in tactfully slowly explaining the importance of the term while being very kind!). EDIT I think I will go with "ezkv" as kiwifruit is probably harder of a change as I can't just grep search and replace everywhere. I also won't to try out the maven redirect stuff. My hesitation of "ezkv" was lack of some symbol for vision memory impression but I think I'm going to go something like "ezkv" lemon squeezy And do a lemon and or lemon tree. What do you think of that name? |
Here is currently the new project name and really really crappy AI image. https://github.com/agentgt/kiwi I haven't yet merged it back to main and renamed the repo yet. |
Project renamed and released into Maven Central: https://github.com/jstachio/ezkv I didn't bother doing the maven relocate thing as the library was so new. I'm really glad @rbygrave was persistent as this would have been more painful to change later. Also I'm curious what you guys think of my SVG logo. I tried the AI generators and I just could not get DALLE to do what I want so I spent the day manually writing SVG code. Yes it is cheesy but I hope it makes it just a little bit more memorable. |
Logo's pretty good, kinda wish it had a little more symmetry
…On Tue, Dec 3, 2024 at 4:41 PM Adam Gent ***@***.***> wrote:
Project renamed and released into Maven Central:
https://github.com/jstachio/ezkv
I didn't bother doing the maven relocate thing as the library was so new.
I'm really glad @rbygrave <https://github.com/rbygrave> was persistent as
this would have been more painful to change later.
Also I'm curious what you guys think of my SVG logo. I tried the AI
generators and I just could not get DALLE to do what I want so I spent the
day manually writing SVG code.
Yes it is cheesy but I hope it makes it just a little bit more memorable.
—
Reply to this email directly, view it on GitHub
<#176 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHWIY4YRRQE7EGKQCZWIRED2DYQO5AVCNFSM6AAAAABOSX5FJ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJVGYYDMNBXGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Well lucky for you it is just code: https://github.com/jstachio/ezkv/blob/main/etc/ezkv_logo.svg?short_path=cbcb632 So you can try a stab at messing with the SVG. That is one thing I do love about SVG because I struggle more trying to figure out drawing tools than just learning some XML. I tried to make the keys kind of look like lemon seeds falling out (squeezed). It does at least look like a lemon right? Also @SentryMan I don't have a windows machine so the fonts could be screwed up. I may need to convert those to line paths (basically it draws the font with lines) with macSVG. If you do can you have a windows machine can you send me a screen shot in discord at some point? |
Parser
Class (it was basically just a map)this is what I got so far, what do you think @agentgt?
Resolves #175