ACM Node.js SDK

Install the ACM Client for Node.js

ACM Client for Node.js makes it possible to help front-end developers release the front and back ends independently, and separate development from operations, which improves the development efficiency dramatically.

Error events handling

acm.on('error', function (err) {
// Logs can be recorded here centrally
// If error events are not listened for, all exceptions get printed to stderr.
});

API description

API for getting configurations

Used to get the configuration from ACM when the service starts.

function* getConfig(dataId, group)

Request parameters

Parameter name

Parameter type

Description

dataId

string

Configuration ID. Use a naming rule like package.class (for example, com.taobao.tc.refund.log.level) to ensure global uniqueness. It is recommended to indicate business meaning of the configuration in the “class” section. All characters must be in lowercase. Only English characters and four special characters (".", ":", "-", and "_") are allowed. It must not exceed 256 bytes.

group

string

Configuration group. We recommend that you use product name: module name (for example ACM: Test) to guarantee the uniqueness. Only English characters and four special characters (".", ":", "-", and "_") are allowed. It must not exceed 128 bytes.

Return values

Parameter type

Description

string

Configuration value

API for configuration listening

If you want ACM to push configuration changes, you can use the ACM dynamic configuration listening interface.

function subscribe(info, listener)

Request parameters

Parameter name

Parameter type

Description

info

Object

Info.dataId: Configuration ID. info.group: Configuration group

listener

Function

Listener. Configuration changes go into the callback function of the listener.

API for canceling configuration listening

Cancels configuration listening when the service starts.

function unSubscribe(info, [listener])

Request parameters

Parameter name

Parameter type

Description

info

Object

info.dataId: Configuration ID. Info.group: Configuration groupp|

listener

Function

Callback function. (Optional, all listener functions are removed if this parameter is not passed in.)