Configuration
Shardus lets you set configuration parameters for how you want your network to operate. This can easily be done when initializing Shardus in your app for the first time. Simply pass in your configuration object to Shardus, and you're done.
const shardus = require("shardus-enterprise-server");
const configs = require("configs");
const baseDirPath = process.env[2] || "./";
const shardus = Shardus({
server: {
baseDir: baseDirPath,
ip: configs.appconfig.ip,
cycleDuration: configs.appconfig.cycleDuration,
reporting: configs.appconfig.reporting,
p2p: configs.appconfig.p2p,
loadDetection: configs.appconfig.loadDetection,
rateLimiting: configs.appconfig.rateLimiting,
stateManager: configs.appconfig.stateManager
}
});
Default configs
Shardus has default configuration parameters set for the network if the config options passed in don't override all the available settings, so don't worry about getting configs set up perfectly. These settings are geared more towards fine tuning the network behavior you want from your application before deploying to production.
Below are the default configurations used by Shardus, if nothing is passed in by the user:
Depending on your type of application and what it demands, it might be wise to experiment beforehand with some of these parameters, just to get familiar with how well your specific application runs.
Shardus takes in 3 root level configuration objects, each having additional nested configs for the module to use:
server
logs
storage
Server
The server configuration deals with network size, load detection, rate limiting, internal peer-to-peer communication, heartbeat intervals, transaction times, cycle durations and much more...
The server config takes in the following parameters:
heartbeatInterval
(Integer)baseDir
(String)transactionExpireTime
(Integer)crypto
(Object)p2p
(Object)ip
(Object)network
(Object)reporting
(Object)debug
(Object)statistics
(Object)loadDetection
(Object)rateLimiting
(Object)stateManager
(Object)sharding
(Object)
Logs
The logs configuration deals with things like log file names, logging output depth and detail, max log file size, and number of backups.
The log config takes in the following parameters:
dir
(String)files
(Object)options
(Object)
Storage
The storage configuration deals with things like database credentials, database host, database logging, dialect, operator aliases, and storage path.
The storage config takes in the following parameters:
database
(String)username
(String)password
(String)options
(Object)