Skip to content
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

Think about how and if to support a ProjectStage #26

Open
struberg opened this issue Nov 16, 2017 · 15 comments
Open

Think about how and if to support a ProjectStage #26

struberg opened this issue Nov 16, 2017 · 15 comments

Comments

@struberg
Copy link
Contributor

Should we introduce a ProjectStage in JSR-382?

@sdaschner
Copy link
Contributor

I would vote for other features, such as the change notification instead. Not that I isn't useful, just about priorities. If I think about real-world scenarios, reloads would IMO help more, e.g.

@hendrikebbers
Copy link
Contributor

I never used a ProjectStage (https://deltaspike.apache.org/documentation/projectstage.html) but what I find quite useful are the profiles in Spring. From my point of view this is more or less the same (don't hit if I'm wrong). I'm currently use this feature often to have different properties for a spring service in Docker / in IDE. So a +1 from me.

@sdaschner
Copy link
Contributor

Yes, AFAIK this is more or less the same than Spring profiles.

This is my point, for enterprise environments at least, that profiles are not a best practice (anymore). We don't want to ship applications that include all configuration permutations for all envs and then decide at runtime, within the application / runtime. Instead, we want to define the (few) parts that are different from the outside and inject the proper configuration then, i. e. via Docker environment variables, volumes, Kubernetes config maps, etc. That means the application includes and "sees" only the final set of configuration values, which are then easily usable by our JSR.

This matches the idea of 12-factor applications of "store config in the environment", see https://12factor.net/config

This is why, at least for modern enterprise environments, I discourage the use of profiles, thus I wouldn't support it (initially).

@lilian-benoit
Copy link

I agree with @sdaschner , a ProjectStage promote internally configuration.
But developers use this system. if that can permit that they don't build artifact per environment
So a +1 from me

@hendrikebbers
Copy link
Contributor

@sdaschner This do not help in non server environments like Java based command line tools or desktop clients ;)

@hendrikebbers
Copy link
Contributor

Discussed today in the weekly:
The preferred way is to simply have a key - value pair that defines the currently profile / stage. This one needs to be added as an argument (for example java.config.stage) to the app. Based on this we only need to define the key name and the pattern how the properties file needs to be named. No specific API is needed.

@jeyvison
Copy link

Based on this we only need to define the key name and the pattern how the properties file needs to be named. No specific API is needed

About that, i think spring uses a very nice and clear way to define a Stage(profile) property file that is application-${profile}.properties. So if a dev profile is passed as parameter when the application starts up the application-dev.properties is loaded.

@hendrikebbers
Copy link
Contributor

Let's discuss naming:

I would prefer javax.config.stage or javax.config.profile as name for the param key to define the profile.

I really like application-${profile}.properties for the config file. As described in #31 the property file name is currently different. So at the moment it would be META-INF/javaconfig-${profile}

@hendrikebbers
Copy link
Contributor

In general I think that profile is a better naming than stage. But maybe this is related to the Spring Boot stuff I did the last 3 years.

@struberg
Copy link
Contributor Author

struberg commented Dec 1, 2017

@jeyvison and how to tweak those settings via env or -D? This way is not really well thought through I fear.
In DeltaSpike we used a postfix

some.server.url vs
some.server.url.Production

@lilian-benoit
Copy link

As deltaspike, have we a list of stage ? or name is completely free ?
it's perhaps the different between stage and profile

I prefer multi-file for stage or profile.

@lilian-benoit
Copy link

But file javaconfig-${stage or profile}.properties overload properties of file javaconfig.properties
We can have only specific properties by this profile or stage

wdyt ?

@jeyvison
Copy link

jeyvison commented Dec 4, 2017

@struberg
We could load the files depending on the pattern(i.e *-dev.properties). If we just use postfix, we may end with a very big file with different configurations for different environments. It may work for small-medium projects, but for large projects this file would be hard to manage.

@lilian-benoit

But file javaconfig-${stage or profile}.properties overload properties of file javaconfig.properties
We can have only specific properties by this profile or stage

Totally agree with this approach. This way we can specify even more what are general and enviroment-specific properties

jeanouii pushed a commit to jeanouii/ConfigJSR that referenced this issue Mar 8, 2018
jeanouii pushed a commit to jeanouii/ConfigJSR that referenced this issue Mar 8, 2018
@jmesnil
Copy link
Contributor

jmesnil commented May 28, 2018

just a bump that the ConfigJSR now has some notion of project stage as mentioned in

ConfigAccessor<T> withLookupChain(String... postfixNames);
.

@struberg I'm not sure whether that was intentional to have it with ConfigAccessor API or if that should have been added by a subsequent PR as there are still some disagreement with that feature as discussed in this thread.

@Emily-Jiang Emily-Jiang added EDR2 and removed EDR2 labels Apr 24, 2019
@Emily-Jiang
Copy link
Member

let's discuss more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants