Module: Krikri::SoftwareAgent

Extended by:
ActiveSupport::Concern
Included in:
Enricher, Harvester, Indexer, Mapper::Agent
Defined in:
lib/krikri/software_agent.rb

Overview

SoftwareAgent is a mixin for logic common to code that generates a ‘Krikri::Activity`.

Software Agents should handle internal errors that do not result in full activity failure, and raise a ‘RuntimeError` when the job fails. `Activity` handles logging of activity start/stop, and failure status.

See Also:

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#agent_nameString

Return an agent name suitable for saving in an Activity. This is the name of the most-derived class upon which this is invoked.

Returns:

  • (String)

See Also:



35
36
37
# File 'lib/krikri/software_agent.rb', line 35

def agent_name
  self.class.agent_name
end

#entity_behaviorObject

Return the EntityBehavior associated with the SoftwareAgent. Meant to be overridden as necessary.



25
26
27
# File 'lib/krikri/software_agent.rb', line 25

def entity_behavior
  @entity_behavior ||= nil
end

#runBoolean

This method is abstract.

Perform this agent’s work. The method may accept an ‘activity_uri` to record as the Activity in provenance metadata. If so, the implementation must be optional and handle `nil` values by declining to record provenance

Returns ‘true` if the run has succeeded; otherwise `false`.

Returns:

  • (Boolean)

    ‘true` if the run has succeeded; otherwise `false`

Raises:

  • (RuntimeError)

    when the software agent’s activity fails

See Also:



51
52
53
# File 'lib/krikri/software_agent.rb', line 51

def run
  fail NotImplementedError
end