init
- init()
- init(url)
- init(options)
Asynchronously initialize the dcp-client bundle for use by the compute API, etc.
- Arguments:
url (string|URL) – Form 2. Scheduler URL location. Equivalent to
init({ scheduler: url }).options (object) – Form 3. An options object – see below.
- Return type:
Promise<object> – an object whose properties are the loaded
dcp/*modules (compute,wallet,worker,protocol,identity,jnu, etc.), each already require()-able asdcp/<name>from this point on.
Note
There is no positional autoUpdate/bundleLocation form. init() only ever takes zero or one argument (a scheduler URL string/URL, or an options object) – a second positional argument is only accepted for a deprecated form (init(dcpConfigFragment, options)) that predates the options.dcpConfig property below and should not be used in new code. Calling init(url, someBoolean), as earlier revisions of this page suggested, does not set autoUpdate at all – it’s silently misinterpreted as the deprecated two-argument form.
Options object properties (Form 3), all optional:
scheduler(string|URL) - Scheduler location. Defaults tohttps://scheduler.distributed.computer/.autoUpdate(boolean) - When true, downloads a fresh dcp-client bundle from the scheduler at startup rather than using the bundle already installed locally.bundleLocation(string|URL) - Where to download the auto update bundle from, ifautoUpdateis set. Defaults to a location derived fromscheduler.parseArgv(boolean) - Whenfalse, skips parsing--dcp-*command-line options (for example,--dcp-scheduler=...) out ofprocess.argv. Defaults totrue, unless theDCP_CLIENT_NO_PARSE_ARGVenvironment variable is set.reportErrors(boolean) - Whenfalse, initialization errors (for example, failure to download the auto update bundle) are thrown instead of logged toconsole.errorwith aprocess.exit(1).configName(string) - Name used to resolve a local config-fragment filename, relative to the program module.dcpConfig(object) - AdcpConfigfragment merged in as part of the default configuration.enableSourceMaps(boolean) - Installssource-map-supportfor more legible error stack traces. Same effect as theDCP_CLIENT_ENABLE_SOURCEMAPSenvironment variable.
Example:
async function main() {
/* DCP App ... */
}
require('dcp-client').init().then(main);
Tutorials:
Node:
dSort,toUpperCase