-
Notifications
You must be signed in to change notification settings - Fork 2.9k
plugin
In pomelo 0.6 we create the plugin mechanism for convenience of developers to extend pomelo as their own demands.
The plugin mainly contains two parts: components and events. The components is necessary while the events is optional according to self demands. The structure is as follow diagram:
Components is the origin components in pomelo, which can refer to pomelo component.In Pomelo, a component is a resusable service unit. A component instance provides some kind of service. A plugin can have several components, and developers can implement different life cycle callbacks, including start, afterStart, stop.
Developers can deal with events in pomelo using events in plugin. The events include add_servers, remove_servers, replace_servers, bind_session, close_session.
- add_servers:add server event,parameter is server information, parameter type is array.
- remove_servers: remove server event,parameter is server information,parameter type is array.
- replace_servers: servers disconnect from intranet(not master) and reconnect event, parameter is servers information which do not disconnect from intranet, parameter type is array.
- bind_session: bind session event, parameter is session object.
- close_session: close session event(including connection close and error), parameter is session object.
###API
####app.use(plugin, opts) use plugin in pomelo ####Arguments
- plugin - plugin that uses in pomelo
- opts - attach parameters
In pomelo only need to configure in app.js, the example code is as follow:
javascript
var statusPlugin = require('pomelo-status-plugin');
app.use(statusPlugin, { status:{ host: '127.0.0.1', port: 6379 } });