app/search/server/service/providerService.js
/**
	 * Stop current provider (if there is one) and start the new
	 * @param id the id of the provider which should be started
	 * @param cb a possible callback if provider is active or not (currently not in use)
	 */
Stop current provider (if there is one) and start the new
@param id the id of the provider which should be started
@param cb a possible callback if provider is active or not (currently not in use)
Stop current provider ( if there is one ) and start the new @param id the id of the provider which should be started @param cb a possible callback if provider is active or not ( currently not in use )
use(id) {
		return new Promise((resolve, reject) => {
			if (!this.providers[id]) { throw new Error(`provider ${ id } cannot be found`); }
			let reason = 'switch';
			if (!this.activeProvider) {
				reason = 'startup';
			} else if (this.activeProvider.key === this.providers[id].key) {
				reason = 'update';
			}
			const stopProvider = () => new Promise((resolve, reject) => {
				if (this.activeProvider) {
					SearchLogger.debug(`Stopping provider '${ this.activeProvider.key }'`);
					this.activeProvider.stop(resolve, reject);
				} else {
					resolve();
				}
			});
			stopProvider().then(() => {
				this.activeProvider = undefined;
				SearchLogger.debug(`Start provider '${ id }'`);
				try {
					this.providers[id].run(reason).then(() => {
						this.activeProvider = this.providers[id];
						resolve();
					}, reject);
				} catch (e) {
					reject(e);
				}
			}, reject);
		});
	}
use ( id ) { return new Promise ( ( resolve , reject ) => { if ( ! this . providers [ id ] ) { throw new Error ( ` ${ id } ` ) ; } let reason = 'switch' ; if ( ! this . activeProvider ) { reason = 'startup' ; } else if ( this . activeProvider . key === this . providers [ id ] . key ) { reason = 'update' ; } const stopProvider = ( ) => new Promise ( ( resolve , reject ) => { if ( this . activeProvider ) { SearchLogger . debug ( ` ${ this . activeProvider . key } ` ) ; this . activeProvider . stop ( resolve , reject ) ; } else { resolve ( ) ; } } ) ; stopProvider ( ) . then ( ( ) => { this . activeProvider = undefined ; SearchLogger . debug ( ` ${ id } ` ) ; try { this . providers [ id ] . run ( reason ) . then ( ( ) => { this . activeProvider = this . providers [ id ] ; resolve ( ) ; } , reject ) ; } catch ( e ) { reject ( e ) ; } } , reject ) ; } ) ; }
Stop current provider (if there is one) and start the new
 @param id the id of the provider which should be started
 @param cb a possible callback if provider is active or not (currently not in use)
Stop current provider ( if there is one ) and start the new @param id the id of the provider which should be started @param cb a possible callback if provider is active or not ( currently not in use )