src/Service/Config/getConfigFromConsul.js
function (logger, key, options) {

    return new Promise((resolve, reject) => {
        var url = `http://${options.host}:${options.port}/v1/kv/${key}`;

        logger.trace(`GET ${url}`);

        request.get(url)
            .timeout(options.timeout)
            .then((res) => {
                logger.trace(`GET ${url} - 200`);
                resolve(res.body);
            })
            .catch((error) => {
                logger.trace(`GET ${url} - ${error.status}`);

                if (error.status === 404) {
                    return resolve(null);
                }

                var code = ConfigError.CODES.UNKNOWN_ERROR;

                if (error.code === 'ECONNREFUSED') {
                    code = ConfigError.CODES.CONSUL_ECONNREFUSED;
                } else if (
                    error.code === 'ECONNABORTED' &&
                    typeof error.timeout === 'number'
                ) {
                    code = ConfigError.CODES.CONSUL_TIMEOUT;
                }

                var exception = ConfigError.createError(code, error);

                exception.bind({method: 'GET', url: url});

                reject(exception);
            });

    });

}
function (logger, key, options) {

    return new Promise((resolve, reject) => {
        var url = `http://${options.host}:${options.port}/v1/kv/${key}`;

        logger.trace(`GET ${url}`);

        request.get(url)
            .timeout(options.timeout)
            .then((res) => {
                logger.trace(`GET ${url} - 200`);
                resolve(res.body);
            })
            .catch((error) => {
                logger.trace(`GET ${url} - ${error.status}`);

                if (error.status === 404) {
                    return resolve(null);
                }

                var code = ConfigError.CODES.UNKNOWN_ERROR;

                if (error.code === 'ECONNREFUSED') {
                    code = ConfigError.CODES.CONSUL_ECONNREFUSED;
                } else if (
                    error.code === 'ECONNABORTED' &&
                    typeof error.timeout === 'number'
                ) {
                    code = ConfigError.CODES.CONSUL_TIMEOUT;
                }

                var exception = ConfigError.createError(code, error);

                exception.bind({method: 'GET', url: url});

                reject(exception);
            });

    });

}
function ( logger , key , options ) { return new Promise ( ( resolve , reject ) => { var url = ` ${ options . host } ${ options . port } ${ key } ` ; logger . trace ( ` ${ url } ` ) ; request . get ( url ) . timeout ( options . timeout ) . then ( ( res ) => { logger . trace ( ` ${ url } ` ) ; resolve ( res . body ) ; } ) . catch ( ( error ) => { logger . trace ( ` ${ url } ${ error . status } ` ) ; if ( error . status === 404 ) { return resolve ( null ) ; } var code = ConfigError . CODES . UNKNOWN_ERROR ; if ( error . code === 'ECONNREFUSED' ) { code = ConfigError . CODES . CONSUL_ECONNREFUSED ; } else if ( error . code === 'ECONNABORTED' && typeof error . timeout === 'number' ) { code = ConfigError . CODES . CONSUL_TIMEOUT ; } var exception = ConfigError . createError ( code , error ) ; exception . bind ( { method : 'GET' , url : url } ) ; reject ( exception ) ; } ) ; } ) ; }
get key form consul kv api

@param  {logger} logger
@param  {String} key
@param  {Object} options
@private
@return {Promise}
get key form consul kv api