https://github.com/transferwise/wise-environment
https://github.com/transferwise/wise-environment
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/transferwise/wise-environment
- Owner: transferwise
- License: other
- Created: 2024-03-22T14:33:37.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-26T14:16:43.000Z (over 1 year ago)
- Last Synced: 2025-02-26T14:42:02.323Z (over 1 year ago)
- Language: Java
- Size: 157 KB
- Stars: 0
- Watchers: 39
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Wise Environment.



[](https://transferwise.atlassian.net/wiki/spaces/EKB/pages/2520812116/Application+Engineering+Team) [](https://wise.enterprise.slack.com/archives/C07QSPFLM5X)
> Use the `@application-engineering-on-call` handle on Slack for help.
---
Provides information to other libraries in which environment they are running in.
Allows to set default properties for specific environments.
Typical use case is for various Wise libraries to set environment specific default properties in their `EnvironmentPostProcessor` implementations.
```java
WiseEnvironment.setDefaultProperty("my-library", WiseEnvironment.PRODUCTION, "tw-reliable-jdbc.sslMode", SslMode.VERIFY_FULL);
WiseEnvironment.setDefaultProperty("my-library", WiseEnvironment.STAGING, "tw-reliable-jdbc.sslMode", SslMode.PREFERRED);
WiseEnvironment.setDefaultProperty("my-library", WiseEnvironment.CUSTOM_ENVIRONMENT, "tw-reliable-jdbc.sslMode", SslMode.VERIFY_CA);
```
See `WiseEnvironment` class for other optional use cases. E.g. asking which environments are currently active.
The environments themselves can be hierarchical. In that sense, that if you set a default property to `STAGING`, it would also apply to
`CUSTOM_ENVIRONMENT`, unless a different value is specifically set for `CUSTOM_ENVIRONMENT`.
Also, a convenience DSL is available for setting properties. E.g.
```java
WiseEnvironment.setDefaultProperties(dsl -> dsl
.source("tw-reliable-jdbc")
.environment(WiseEnvironment.WISE)
.set(TW_OBS_BASE_EXTREMUM_CONFIG_PATH, gaugeNames)
.set("spring.flyway.validate-migration-naming", "true")
.keyPrefix("tw-reliable-jdbc.")
.environment(WiseEnvironment.PRODUCTION)
.set("sslMode", SslMode.VERIFY_FULL)
.set("requiredSslModeLevel", SslMode.VERIFY_CA)
.set("requireMinPoolSizePct", 100d)
.environment(WiseEnvironment.STAGING)
.set("sslMode", SslMode.VERIFY_FULL)
);
```
## License
Copyright 2024 TransferWise Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.