AgentDispatcher (solid infrastructure fundamentals for script based agents)

v0.7.0

A non-intrusive application micro-framework that turns your plain ruby objects into configurable, reactive, and easily operable agents. They will react on commands; combine behaviors using dynamic configurations; multiply instances, play nice with with *nix infrastructure. In other words, object-oriented, shell-script-enabled approach towards agents modelling.

There are two types of dispatchers (mixins) available:

  • SimpleDispatcher - reacts on commands, runs with pid, commandline invocation, concept of instance id. (obsolete)

  • AgentDispatcher - additionally to SimpleDispather it adds configurations, command-line configuration, constructor/destructors, logging

The main mixin is AgentDispatcher. See datailed description and examples in docs of the each class.

Features

  • dispatching of commands with arguments. Handled by on_#{command} callback methods.

  • static definition of acceptable commands (@AllowedCommands)

  • PORO (Plain Old Ruby Objects) - the behavior can be applied (mixed-in) to any class not interfering

    • own methods, own constructor

  • chain of inheritable custom constructor and destructor methods (upMethod, downMethod)

  • hierarchical (layered) configuration (code-provided defaults < config files < manual parameters on invocation)

  • configurations by absolute path, or config file name

  • class defined configuration defaults (@DefaultCfg)

  • configuration overlays (something like multiple class inheritance) (@cfg)

  • sensible default behaviors (id, command, config do not have to be provided)

  • identity (agent instance id) (@id)

  • pid file management

  • customizable ROOT path (where resources are found, logs, pids written) (AGENTS_ROOT)

  • logging per instance (can be overriden) (@log)

Options:

--config=A,B,C - cofiguration files
--log_path         - custom log path
--pid_path         - custom pid path
--nopid              - dont mess with pid files, neither write, nor consider pid file
--forcepid          - starts even if pid file exists
--quiet               - no output

Instance variables:

@id, @log, @cfg

Run rake rdoc for documentation and examples. See examples

Instalation

World-wide installation:

- Available as gem: <tt>gem install agentdispatcher</tt>
- Project homepage http://rubyagent.rubyforge.org/
- Project development page, downloads, forum, svn: http://rubyforge.org/projects/rubyagent/

Local gem creation:

rake gem
rake test  #to run all testcases
sudo gem install pkg/agentdispatcher-x.y.z.gem  --local

Author

Copyright © 2008 Viktor Zigo, alephzarro.com

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program (LICENSE file); if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Sponsored by: 7inf.com

TODO:

HighPri:

- adjust to support agent caching (reuse)

LowPri:

- help (for simple dispatcher)
- not existing runtime - try to create it
- validate input/cfg (just by exposing a method, subclassing DynParser)
- adjust simpleDispatcher to compatible behavior with agentDispatcher (constructor)