FleetConf::Agent::Context

FleetConf::Agent::Context is an agent context module.
Download

FleetConf::Agent::Context Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Andrew Sterling Hanenkamp
  • Publisher web site:
  • http://search.cpan.org/~hanenkamp/

FleetConf::Agent::Context Tags


FleetConf::Agent::Context Description

FleetConf::Agent::Context is an agent context module. FleetConf::Agent::Context is an agent context module.This is the API that grants access to the runtime context of an agent. This context provides for a simple way of accessing the current workflow record, declaring, fetching, and storing values in lexically scoped variables, allocating record locks, performing commits and rollbacks, and logging to the workflow record (though, these latter features should not be used directly in most instances).This class defines the following methods:$ctx = FleetConf::Agent::Context->new($this)Creates a new workflow record context. The $this argument is used as the current workflow record and must be a reference to a hash (an empty anonymous reference is fine).A new context object is returned.$value = $ctx->get($key)Fetches the value $value from the context variable $key or returns undef if no such value is found. The returned value will always be a scalar value (i.e., possibly a reference to something, but still a single scalar).$ctx->set($key, $value)Sets the value for context variable named $key to the value given in $value. The given value must be a scalar and will overwrite any current value.$ctx->push_scopeThis method pushes a frame onto the lexical stack within the current context. Variables declared in a nested scope are deallocated when the pop_scope method pops that scope off the lexical stack.$ctx->pop_scopeThis method pops the top frame from the lexical stack within the current context. Any variables held within that frame are deallocated and lose their value.$success = $ctx->begin($mnemonic)Do not use this unless you know exactly what you're doing.This attempts to acquire the named ($mnemonic) lock on the current workflow record and returns whether or not the lock succeeded.$ctx->commitDo not use this unless you know exactly what you're doing.This tells the current workflow record to commit any changes made back to the workflow. If an error has occurred (i.e., a log message with level "error" was recorded), then this commit should be noted to have been performed with an error (which may require some sort of intervention). The lock will be released after this call is made.$ctx->rollbackDo not use this unless you know exactly what you're doing.This tells the current workflow record to rollback any changes made to the workflow. Thus, nothing should be recorded with the workflow and the lock on the workflow record should be released. This can be done if an error occurred and any intermediate changes made by this agent can be undone.$ctx->log($level, @message)Do not use this unless you know exactly what you're doing.This method logs a message on the current workflow record. Acceptable levels should be: debug info notice warning error alert emergencyThis method will be called automatically via the regular logging API exposed via $FleetConf::log, so this shouldn't be called directly under nearly any circumstance.$out_str = $ctx->interpolate($in_str)Given a string $in_str, this method returns a string $out_str with all instances of "${variable_name}" found in the input string replaced with the value that would be returned if that variable name were passed to the get method. Requirements: · Perl


FleetConf::Agent::Context Related Software