Skip to content

Releases: advantageous/konf

Konf Java configuration with JSON, YAML and JavaScript version 1.3.6.RELEASE

05 May 07:59
Compare
Choose a tag to compare

We opened up the resource management when we create konf-boon-json, konf-yaml-bean, and konf-typesafe-conf.
We did this so we did not have to repeat this code. We also support number handling better.

Konf Java configuration with JSON, YAML and JavaScript version 1.3.0.RELEASE

02 May 01:28
Compare
Choose a tag to compare

Konf Website

We also found out on our own project that we were missing getBoolean(path) and getBooleanList(path), so we added them. The getX for numbers was modified so that it does parse a string so if the string is a number "123" or in the case of float or double "12.3". We did this mainly so we could access environment variables easily.

We added these helper functions to the JavaScript config.

JavaScript functions that we support

  • sysProp(propName) to read a sysProp as in fooSize : sysProp("my.foo.size")
  • sysPropOrDefault(propName, defaultValue) to read a sysProp or a default
  • isWindowsOS(), isMacOS(), isUnix(), isLinux(), isSolaris()
  • env() as in fooSize : env('MY_FOO_SIZE') or even fooSize : sysPropOrDefault("my.foo.size", env('MY_FOO_SIZE'))
  • uri() which creates a java.net.URI as in fooURI : uri ("http://localhost:8080/")
  • java.time.Duration is imported as duration
  • java.lang.System is imported as system
  • seconds(units), minutes(units), hours(units), days(units), millis(units) and milliseconds(units) define a Duration which is useful for configuring timeouts and interval jobs

Working with java.lang.Boolean for Java Config.

  • getBoolean(path) read a boolean
  • getBooleanList(path) read a list of booleans

Documented using Konf to define your own DSL

Defining your own config DSL with Konf

You can define you own config DSL for your environment.
We have a full example that shows you how to create a custom config DSL
for your internal projects. The example uses Mesosphere and Docker PORT
look ups and it is from a real project.

Defining your own config DSL

var config = {

  platform: {

    statsd: "udp://" + getDockerHost() + ":8125",

    servicePort: mesosPortAt(0, 8080),
    adminPort: mesosPortAt(1, 9090),
    ...

Using different resources when you load config

        config = ConfigLoader.load(
                      "/io/mycompany/foo-classpath.js",
                      "classpath:test-config.js",
                      "classpath://foo.js",
                      "classpath:/bar.js",
                      "file://opt/app/config.js",
                      "file:///opt/app/config2.js",
                      "file:/opt/app/config.js",
                      "http://my.internal.server:9090/foo.js"
                      );

getMemorySize

We now support getMemorySize(path) and getMemorySizeList(path).

    /**
     * Get a ConfigMemorySize  at location
     *
     * @param path path
     * @return string at location.
     */
    ConfigMemorySize getMemorySize(String path);

    /**
     * Get a ConfigMemorySize  list at location
     *
     * @param path path
     * @return string at location.
     */
    List<ConfigMemorySize > getMemorySizeList(String path);

This means we support config like:

  diskSpace : " 10 gigabytes",
  diskVolumes : [" 10 gigabytes", "10GB", "10 gigabytes", 10]

Thanks

If you like our configuration project, please try our
Reactive Java project
or our Actor based microservices lib.

Konf Java configuration with JSON, YAML and JavaScript version 1.1.0.RELEASE

29 Apr 02:05
Compare
Choose a tag to compare

Added getDuration(path), getIntList(path), and the rest of the numbers (double, float, long).

Working with java.time.Duration

  • getDuration(path) get a duration
  • getDurationList(path) get a duration list

Konf supports "10 seconds" style config for duration as well as
having built-in functions and support for ISO-8601. See documentation
for duration config
for more details.

Konf can reads list of numbers.

  • getIntList reads list of ints
  • getLongList reads list of longs
  • getDoubleList reads list of doubles
  • getFloatList reads list of floats

See documentation list of number configuration
for more details.

Thanks

If you like our configuration project, please try our
Reactive Java project
or our Actor based microservices lib.

First release, Konf Java configuration system

28 Apr 02:06
Compare
Choose a tag to compare

First release, Konf Java configuration system.