Base class for sitespeed.io plugins. Extend it,
implement processMessage, and sitespeed.io will instantiate and drive your
plugin through the message queue.
See the plugin documentation for the full plugin lifecycle.
npm install @sitespeed.io/pluginimport { SitespeedioPlugin } from '@sitespeed.io/plugin';
export default class MyPlugin extends SitespeedioPlugin {
constructor(options, context, queue) {
super({ name: 'myplugin', options, context, queue });
}
async open() {
// optional: setup on startup
}
async processMessage(message) {
if (message.type === 'url') {
this.log.info('Got a URL: %s', message.url);
await this.sendMessage('myplugin.data', { hello: 'world' });
}
}
async close() {
// optional: cleanup on shutdown
}
}this.name/getName()— plugin namethis.options/getOptions()— sitespeed.io start optionsthis.context/getContext()— sitespeed.io contextthis.queue— the message queuethis.log/getLog()— logger (call levels directly:this.log.info(...))getStorageManager()— storage manager for writing filesgetFilterRegistry()— filter registry for TimeSeries metricssendMessage(type, data, extras)— post a message on the queueopen()/close()— lifecycle hooks (override as needed)processMessage(message)— must be implemented by your subclass
MIT