-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration System
The Core provides you with a centralized Configuration System to get rid of copying configs around the world on your server. This allows you to store configs that are synchronized over the whole network in one place. For this, I decided to use .properties
as the only available format to allow storage of all kinds of data you might want to store. The API provides you with a whole system to read and modify these configs. It is technically possible to use these configs as a database but it is highly recommended. If you want to store data, then please use the JDBI API provided by the Core!`
The Configurations are stored all in one place and are identified via a unique name. To locate the folder used to store the configurations, open the working directory of your Master. There should be a folder called "config", that by default contains two or one file. Among these files should be one that is called database.properties
, this is your way to enter your database credentials. All your custom configurations will be saved here. If you copy a configuration in this folder, it will be loaded by the Master and distributed to all cores on the cluster. You can trigger the "loading" of the configs also manually by entering the command rlconfig
into the Master terminal. In the case you would like to save the configs manually you can use svconfig
- These commands are of cause also available via the CoreCommand System - so it is possible to trigger these actions from every core connected to the cluster (and also from the web interface for advanced users and developers)
The Configuration System is designed that creates your configurations as soon as you try to load "get" them. To create your Configuration I suggest using the following method:
Configuration yourConfig = API.get().getConfigurationApi().getOrCreate("name_of_your_config");
It is also possible to enter a properties object here to provide "defaults" - this is for advanced users so I will only describe the basics of using this. To use the defaults, it is important to understand, that the behavior of this method changes regarding the existence of the config prior to the execution of this method.
The first thing you need to do is create your Properties and enter the configuration_name
final Properties defaults = new Properties();
defaults.setProperty("configuration_name","name_of_your_config");
There are currently two "keys" reserved for internal use in every config: configuration_name
& configuration_header
the configuration_header
will be printed as a comment at the start of the file that is saved.
Now you could decide to set the header or leave it at default.
You can also use the following method to do the same thing as explained above:
final Properties defaults = API.get().getConfigurationApi().initializeProperties("name_of_your_config", "my custom header");
After this necessary setup, you can enter your defaults like this:
defaults.setProperty("test", "Value");
defaults.setProperty("hu", "he");
defaults.setProperty("Paper", "Brick");
defaults.setProperty("Hard-fork", "no thanks!");
Please remember that it only suggested entering Strings here, you can always enter stuff after the creation of the config and use literally all datatypes you like! But all "String forms" of primitive datatypes are theoretically supported.
Now you are ready to create your Configuration out of our defaults:
final Properties defaults = new Properties();
defaults.setProperty("configuration_name","name_of_your_config");
defaults.setProperty("test", "Value");
defaults.setProperty("hu", "he");
defaults.setProperty("Paper", "Brick");
defaults.setProperty("Hard-fork", "no thanks!");
Configuration defaultConfig = API.get().getConfigurationApi().getOrCreate(defaults);
If you need assistance with your setup, development, or configuration, feel free to reach out to me via email ©Ture Bentzin 2023