Project

General

Profile

Actions

How to Create a Smart-Proxy Plugin » History » Revision 3

« Previous | Revision 3/30 (diff) | Next »
Anonymous, 07/24/2014 08:11 AM


How to Create a Smart-Proxy Plugin

This guide outlines main components of a plugin, but skips details of ruby gems and bundler. Please refer to http://rubygems.org and http://bundler.io respectively for documentation and examples.

Plugin Organization

Smart-Proxy plugins are normal ruby gems, please follow documentation at http://guides.rubygems.org/make-your-own-gem/ for guidance on gem creation and packaging. It is strongly recommended to follow smart_proxy_<your plugin name here> naming convention for your plugin. You can use smart_proxy_pulp plugin as an example -- a fully functional, yet easy to understand Smart-Proxy plugin.

Plugin Definition

Plugin Definition is used to define plugin's name, version, location of rackup configuration, and other parameters. At a minimum, Plugin Descriptor must define plugin name and version. Note the base class of the descriptor is ::Proxy::Plugin:

class ExamplePlugin &lt; ::Proxy::Plugin
  plugin :example, "0.0.1" 
  http_rackup_path File.expand_path("http_config.ru", File.expand_path("../", __FILE__))
  https_rackup_path File.expand_path("https_config.ru", File.expand_path("../", __FILE__))
end

Here we defined a plugin called "example", with version "0.0.1", that is going to listen on both http and https ports. Following is the full list of parameters that can be defined by the Plugin Descriptor.

  • plugin :example, "1.2.3": required. Sets plugin name to "example" and version to "0.0.1".
  • http_rackup_path "path/to/http_config.ru": optional. Sets path to http rackup configuration. If omitted, the plugin is not going to listen on the http port. Please see below for information on rackup configuration.
  • https_rackup_path "path/to/https_config.ru": optional. Sets path to https rackup configuration. If omitted, the plugin is not going to listen on the https port. Please see below for information on rackup configuration.
  • requires :another_plugin, '~> 1.2.0': optional. Specifies plugin dependencies, where ":another_plugin" is another plugin name, and '~> 1.2.0' is version specification (pls. see http://guides.rubygems.org/patterns/#pessimistic_version_constraint for details on version specification).
  • default_settings :first => 'my first setting', :another => 'my other setting': optional. Defines default values for plugin parameters. These parameters can be overridden in plugin settings file.
  • after_activation { do_something }: optional. Supplied block is going to be executed after the plugin has been loaded and enabled. Note that the block is going to be executed in the context of the Plugin Descriptor class.
  • bundler_group :my_plugin_group: optional.

Updated by Anonymous almost 10 years ago · 3 revisions