GWicke has uploaded a new change for review. https://gerrit.wikimedia.org/r/257213
Change subject: Export a service-runner compatible entry point ...................................................................... Export a service-runner compatible entry point This patch adds a service-runner compatible entry point to Parsoid's public mudule API. Using this entry point, it is possible to run Parsoid using service-runner. Among other things, this also allows us to run Parsoid, RESTBase and other services in a single node process. Change-Id: Ia057823d0173dcff090c1afef329b4cf64de8d73 --- M lib/config/ParsoidConfig.js M lib/index.js 2 files changed, 18 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/13/257213/1 diff --git a/lib/config/ParsoidConfig.js b/lib/config/ParsoidConfig.js index 110ccaa..26ee8a3 100644 --- a/lib/config/ParsoidConfig.js +++ b/lib/config/ParsoidConfig.js @@ -91,6 +91,7 @@ * @param {Object} options Any options we want to set over the defaults. Will not overwrite things set by the localSettings.setup function. See the class properties for more information. */ function ParsoidConfig(localSettings, options) { + var self = this; this.mwApiMap = new Map(); this.reverseMwApiMap = new Map(); this.mwApiRegexp = ""; @@ -106,6 +107,12 @@ // This happily overwrites inherited properties. if (options) { Object.assign(this, options); + // Call setMwApi for each specified API. + if (Array.isArray(options.mwApis)) { + options.mwApis.forEach(function(api) { + self.setMwApi(api); + }); + } } if (this.loadWMF) { diff --git a/lib/index.js b/lib/index.js index 1369874..d580e19 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,6 +4,7 @@ var json = require('../package.json'); var parseJs = require('../bin/parse.js'); var ParsoidConfig = require('./config/ParsoidConfig.js').ParsoidConfig; +var ParsoidService = require("./api/ParsoidService.js"); var JsApi = require('./jsapi.js'); /** @@ -136,3 +137,13 @@ Object.keys(JsApi).forEach(function(k) { Parsoid[k] = JsApi[k]; }); + +/** + * Start an API service worker as part of a service-runner service. + * @param {object} options + * @return {Promise<void>} + */ +Parsoid.apiServiceWorker = function apiServiceWorker(options) { + var parsoidConfig = new ParsoidConfig(null, options.config); + return ParsoidService.init(parsoidConfig, options.logger); +} -- To view, visit https://gerrit.wikimedia.org/r/257213 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia057823d0173dcff090c1afef329b4cf64de8d73 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: GWicke <gwi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits