Having modules allows an amazing level of flexibility. Plus it is really cool. Heh. But seriously, modules allow a clean separation of the core code and support modules, and makes multi-platform support an (almost) orthogonal issue.
There are three classes of modules:
Class | E.g. | Remark |
---|---|---|
OS support | OS_LINUX OS_IRIX |
Provides platform support. This class of modules gets loaded automatically when bongoyo starts. |
HA support | LPRNG TCPCONN NULL TRUE EXEC |
Provides support for the HA functions, like detecting failed services and performing IP pre-takeover functions. This class of modules gets loaded when the configuration file is parsed. |
Others | None yet | Provide other form of support, e.g., built-in webserver for status viewing. This class of modules will probably get loaded when the configurawtion file is parsed. Still in the wish list state. :-( |
The best way is to look at one of the existing modules.
For the OS support and HA support module classes, what happens when a module gets loaded is that it register the functions it provides, e.g.:
And the core bongoyo program will call the correct functions.BEGIN { # register our functions $::s_oursub{get_our_ips} = \&OS_LINUX_get_our_ips; $::s_oursub{takeover_ip} = \&OS_LINUX_takeover_ip; $::s_oursub{release_ip} = \&OS_LINUX_release_ip; }
For the third class of modules, it is pretty much whatever goes.
This module provides two functions: (1) service_check to be used by the boss to see if an LPRNG server is up, and (2) suitability_self_check to be used by each fail-over server to see if itself is suitable to assume the duty of an LPRng print server when the need arrises.
The main difference between an LPRng lpd and a regular BSD lpd (as far as this module is concerned) is that the LPRng lpd accepts connection from any port of the remote end where as the BSD lpd accepts connection from remote port of 721-731 only. This makes the LPRng module a little easier to write.
Requires a parameter specifying the print queue on the virtual server to check for. This print queue had better print to /dev/null because the check will come once every 30 seconds or so.
Requires no parameter. Basically what it does is to open up a connection to 515/tcp. If the connection is accepted, it will be closed immediately.
Provides generic functions for checking listening TCP ports for both service_check and suitability_self_check. All it does is to initiate a TCP connection to the target port. They both require a parameter specifying the port to connect to.
Provides a generic method to execute external programs for functions: service_check, suitability_self_check, pre_takeover, post_takeover, pre_release and post_release. It takes two or more parameters. The first parameter gives the timeout in seconds that the external call is considered to have failed. The second parameter is the external program to be executed. Any more parameters will be passed on as paramters to the external program.
Provides service_check and suitability_self_check functions that always return true.
Provides pre_takeover, post_takeover, pre_release and post_release functions that do nothing except to report that the task is done.
TRUE and NULLare very similar and might be merged into one in the future.
Page mangling by Edwin Lim.
Tue Sep 12 02:28:34 EDT 2000