Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
py edited this page Aug 22, 2013 · 5 revisions

In pomelo 0.6 we create the plugin mechanism for convenience of developers to extend pomelo as their own demands.

Structure

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:

plugin

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.

How to use

###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 } });



Clone this wiki locally