Harpseal Base¶
Harpseal App¶
Harpseal app, includes web server and harpseal daemon.
-
class
harpseal.app.
Harpseal
(conf='config.json')[source]¶ Bases:
harpseal.plugin.PluginMixin
Harpseal daemon.
-
config
= None¶ (
harpseal.conf.Config
) Harpseal configuration
-
loop
= None¶ (
asyncio.BaseEventLoop
) Base event-loop
-
periodic_task
()[source]¶ Store a new mongo instance with given plugin data to mongodb when got a new result.
-
plugins
= None¶ (
tuple
) Plugins
-
start
(loop)[source]¶ Start a web server and periodic task after register and execute plugins.
Parameters: loop – Base event-loop
-
tasks
= None¶ (
tuple
) Tasks (by plugins)
-
web
= None¶ (
harpseal.web.WebServer
) Harpseal API server
-
Harpseal Classes¶
Classes, include Mixin, Task and others.
-
class
harpseal.classes.
PeriodicTask
(plugin, app)[source]¶ Bases:
object
A class for creating periodic task.
-
plugin
= None¶ (
harpseal.plugin.Plugin
) Target plugin to run periodically
-
Config parser¶
Harpseal config parser based on JSON
Harpseal Plugin¶
-
class
harpseal.plugin.
Plugin
[source]¶ Bases:
object
Base plugin model
Usage:
import asyncio from harpseal.plugin import Plugin class YourPlugin(Plugin): name = '(required) your-plugin-name' description = '(required) plugin description here' priority = 0 # not yet implemented every = 1 # every 1 minute def init(self): # graph type definitions self.field_types['a'] = 'line' self.field_types['b'] = 'stack' self.field_types['c'] = 'full-stack' # field type definitions (`int` or `float`) self.fields['a'] = [('normal', int, ), ('abnormal', int, ), ] self.fields['b'] = [('normal', float, ), ('abnormal', float, ), ] self.fields['c'] = [('normal', float, ), ('abnormal', float, ), ] @asyncio.coroutine def provider(self): # data provider data = self.data_form() data['a'].set('normal', 100) data['a'].set('abnormal', 150) # ... return data
-
call
(command)[source]¶ Execute a command on the event-loop and then return the result when finished.
-
description
= ''¶ Plugin description
-
every
= 1¶ Plugin execution cycle (minutes)
-
field_types
= None¶ (
collections.defaultdict
) Model field type definitions (line, stack, full-stack, bar)
-
fields
= None¶ (
collections.defaultdict
) Model field definitions
-
last_executed_at
= None¶ (
datetime.datetime
) Last executed time
-
last_executed_result
= None¶ (
bool
) Last executed result
-
models
= None¶ (
dict
) Model definitions to be stored after executed init method
-
name
= ''¶ Plugin name
-
priority
= 0¶ Execution priority
-
properties
¶ Return the instance properties as a dict.
-