Module: Locd::Agent::System
- Included in:
- Proxy, RotateLogs
- Defined in:
- lib/locd/agent/system.rb
Overview
Mixin for common stuff that system agents do different.
System agents are specific types of Locd::Agent built in to Loc'd to handle things like proxying HTTP request site (Proxy), rotating logs so they don't get unwieldily (RotaeLogs), and probably more in the future, like serving a site index, API, etc.
System agents are singular - there's only one of each for a Loc'd
label namespace, which is set via the configuration, and Loc'd uses
that label namespace, together with the each system agent's .label_name,
to form the agent's unique label, which is how it finds the system agents.
This was really just to make it simpler by side-stepping how to handle many proxies and log rotators and such because besides the dev/release situation described above I can't really think of any reason you would want to create and manage multiple of each system agent.
As a consequence, Locd::Agent subclasses that mix System
in must define a .label_name class method.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- @@classes =
Hamster::Set.new
Class Method Summary collapse
-
.class_for(plist) ⇒ Class<Locd::Agent>?
Find the concrete Locd::Agent subclass (that has mixed in System) for a property list.
- .classes ⇒ Object
- .included(base) ⇒ Object
- .label?(label) ⇒ Boolean
-
.plist?(plist) ⇒ Boolean
Is a plist for one of this config's system agents?.
Class Method Details
.class_for(plist) ⇒ Class<Locd::Agent>?
Find the concrete Locd::Agent subclass (that has mixed in Locd::Agent::System) for a property list.
82 83 84 85 86 |
# File 'lib/locd/agent/system.rb', line 82 def self.class_for plist return nil unless plist?( plist ) classes.to_a.find_bounded( max: 1 ) { |cls| cls.plist? plist }.first end |
.classes ⇒ Object
38 39 40 |
# File 'lib/locd/agent/system.rb', line 38 def self.classes @@classes end |
.included(base) ⇒ Object
89 90 91 92 |
# File 'lib/locd/agent/system.rb', line 89 def self.included base base.extend ClassMethods @@classes = @@classes.add base end |