e_components

Overview

The e_components main purpose is to provide the possibility of widening the scope of Erlang Web functionalities without modification of the 3 (or, in case of scalable EW 4 (eptic_fe)) core applications. Each of the e_components is a separate Erlang application, which has the following attributes:

  1. the source code - since Erlang Web is the Open Source project, we should accept only open solutions
  2. the documentation - e_component should contain the clear documentation which covers the basic usability, all the features, API (edoc?) and the examples

Adding the e_components to the project

User attach the e_component into the existing project built on top of Erlang Web by specifying its name and configuration in the project.conf file.

If you are building target systems with systools, you should add the e_components as included_applications in the .app file of one of your ordinary applications, and also add them to the .rel file.

Example

User wants to add two e_components to his environment. First one is wpart_rss with no configuration parameters and the latter is the ew_backup with the parameters describing the backup frequency and the backups destination directory.

The part of the project.conf dealing with e_components registration should look like:

...
{ecomponents, [{wpart_rss, []},
               {ew_backup, [{frequency, {12, hour}},
                            {output_directory, "backups"}]}}.
...

Implementing the e_component

As it was mentioned before, the e_component must be an Erlang application. Since the other than OTP dependency and configuration manager is used, it is strongly recommended not to provide the mod clause in the .app file. Instead of doing that, all the actions which should be performed during the e_component start should be moved to the install/1 function.

e_component behavior

The following functions are mandatory for the e_component implementation:

  1. install(Configuration) - does all the necessary actions to set up the environment for the new e_component (like registering itself to the wpart supervisor (or other one), creating the ets tables and so on). The argument it takes - Configuration - is the list of the parameters specified in the project.conf file.

  2. uninstall(Configuration) - called during the e_component removal process. The configuration is the same as in the install/1 function case.

  3. dependecies() - returns a list of the dependencies - the e_components which are required for this e_component to run. The list should be in format:

     [{EcomponentName, {MinVersion, MaxVersion}}]

    where MinVersion and MaxVersion could be either a number or an undefined atom (to indicate the given version does not matter).

Example

The example of the e_mnesia_auth e_component, which requires the e_auth e_component at least in version 1.2:

...
install(Config) ->
  TblName = proplists:get_value(table_name, Config),

  Spec = {?MODULE, {?MODULE, start_link, [TblName]}, 
          permanent, 2000, worker, [?MODULE]},
  supervisor:start_child(wpart, Spec).

uninstall(_Config) ->
   case supervisor:terminate_child(wpart, ?MODULE) of
    ok ->
        supervisor:delete_child(wpart, ?MODULE);
    Else ->
        Else
   end.

dependencies() ->
   [{e_auth, {1.2, undefined}}].
...

e_components repository

In order to make the e_components usage easier there is an e_component repository set up and the installation script attached. Each of the e_component stored in the repository is described by the following parameters:

The installation script usage:

The possible extensions of the script are:

The repository address is http://ecomponents.erlang-web.org

The second script is named e_component_uploader.erl and will be available only for contributors. Its only duty is to login to submit new components on the server so they will be available for download. Of course, there is a basic authentication implemented, so it will not be possible for anonymous people to mess up in the repository.

The usage is as follows:

Available e_components

So far, the following e_components have been implemented:

Ecomponents/Overview (last edited 2009-07-15 09:20:38 by michal.zajda)