Documentation ¶
Index ¶
- Constants
- Variables
- func UnmarshalBody(in interface{}, body io.ReadCloser) (int, error)
- type AvailablePlugin
- type CatalogedMetric
- type CatalogedPlugin
- type Metric
- type Namespace
- func (n Namespace) AddDynamicElement(name, description string) Namespace
- func (n Namespace) AddStaticElement(value string) Namespace
- func (n Namespace) AddStaticElements(values ...string) Namespace
- func (n Namespace) Element(idx int) NamespaceElement
- func (n Namespace) IsDynamic() (bool, []int)
- func (n Namespace) Key() string
- func (n Namespace) String() string
- func (n Namespace) Strings() []string
- type NamespaceElement
- type Plugin
- type PluginCatalog
- type PluginType
- type RequestedMetric
- type RequestedPlugin
- func (p *RequestedPlugin) AutoLoaded() bool
- func (p *RequestedPlugin) CheckSum() [sha256.Size]byte
- func (p *RequestedPlugin) Path() string
- func (p *RequestedPlugin) ReadSignatureFile(file string) error
- func (p *RequestedPlugin) SetAutoLoaded(isAutoLoaded bool)
- func (p *RequestedPlugin) SetPath(path string)
- func (p *RequestedPlugin) SetSignature(data []byte)
- func (p *RequestedPlugin) Signature() []byte
- type Schedule
- type SubscribedPlugin
- type Task
- type TaskCreationRequest
- type TaskErrors
- type TaskOption
- type TaskState
- type TaskWatcherCloser
- type TaskWatcherHandler
- type Workflow
- type WorkflowState
Constants ¶
const (
// Separator is the default separator used in strings
Separator = "\U0001f422"
)
Variables ¶
var ( // ErrSubscriptionGroupAlreadyExists - error message when the subscription // group already exists ErrSubscriptionGroupAlreadyExists = errors.New("Subscription already exists") // ErrSubscriptionGroupDoesNotExist - error message when the subscription // group does not exist ErrSubscriptionGroupDoesNotExist = errors.New("Subscription does not exist") )
var ( // Standard Tags are in added to the metric by the framework on plugin load. // STD_TAG_PLUGIN_RUNNING_ON describes where the plugin is running (hostname). STD_TAG_PLUGIN_RUNNING_ON = "plugin_running_on" )
var ( TaskStateLookup = map[TaskState]string{ TaskDisabled: "Disabled", TaskStopped: "Stopped", TaskSpinning: "Running", TaskFiring: "Running", TaskEnded: "Ended", TaskStopping: "Stopping", } )
Functions ¶
func UnmarshalBody ¶
func UnmarshalBody(in interface{}, body io.ReadCloser) (int, error)
Types ¶
type AvailablePlugin ¶
type CatalogedMetric ¶
type CatalogedMetric interface { RequestedMetric LastAdvertisedTime() time.Time Policy() *cpolicy.ConfigPolicyNode Description() string Unit() string }
type CatalogedPlugin ¶
type CatalogedPlugin interface { Plugin IsSigned() bool Status() string PluginPath() string LoadedTimestamp() *time.Time Policy() *cpolicy.ConfigPolicy }
the public interface for a plugin this should be the contract for how mgmt modules know a plugin
type Metric ¶
type Metric interface { RequestedMetric Config() *cdata.ConfigDataNode LastAdvertisedTime() time.Time Data() interface{} Tags() map[string]string Timestamp() time.Time Description() string Unit() string }
Metric represents a snap metric collected or to be collected
type Namespace ¶
type Namespace []NamespaceElement
func NewNamespace ¶
NewNamespace takes an array of strings and returns a Namespace. A Namespace is an array of NamespaceElements. The provided array of strings is used to set the corresponding Value fields in the array of NamespaceElements.
func (Namespace) AddDynamicElement ¶
AddDynamicElement adds a dynamic element to the given Namespace. A dynamic NamespaceElement is defined by having a nonempty Name field.
func (Namespace) AddStaticElement ¶
AddStaticElement adds a static element to the given Namespace. A static NamespaceElement is defined by having an empty Name field.
func (Namespace) AddStaticElements ¶
AddStaticElements adds a static elements to the given Namespace. A static NamespaceElement is defined by having an empty Name field.
func (Namespace) Element ¶
func (n Namespace) Element(idx int) NamespaceElement
func (Namespace) IsDynamic ¶
IsDynamic returns true if there is any element of the namespace which is dynamic. If the namespace is dynamic the second return value will contain an array of namespace elements (indexes) where there are dynamic namespace elements. A dynamic component of the namespace are those elements that contain variable data.
func (Namespace) Key ¶
Key returns a string representation of the namespace with "." joining the elements of the namespace.
type NamespaceElement ¶
NamespaceElement provides meta data related to the namespace. This is of particular importance when the namespace contains data.
func NewNamespaceElement ¶
func NewNamespaceElement(e string) NamespaceElement
NewNamespaceElement tasks a string and returns a NamespaceElement where the Value field is set to the provided string argument.
func (*NamespaceElement) IsDynamic ¶
func (n *NamespaceElement) IsDynamic() bool
IsDynamic returns true if the namespace element contains data. A namespace element that has a nonempty Name field is considered dynamic.
type PluginCatalog ¶
type PluginCatalog []CatalogedPlugin
the collection of cataloged plugins used by mgmt modules
type PluginType ¶
type PluginType int
const ( // List of plugin type CollectorPluginType PluginType = iota ProcessorPluginType PublisherPluginType )
func ToPluginType ¶
func ToPluginType(name string) (PluginType, error)
func (PluginType) String ¶
func (pt PluginType) String() string
type RequestedMetric ¶
RequestedMetric is a metric requested for collection
type RequestedPlugin ¶
type RequestedPlugin struct {
// contains filtered or unexported fields
}
func NewRequestedPlugin ¶
func NewRequestedPlugin(path string) (*RequestedPlugin, error)
func (*RequestedPlugin) AutoLoaded ¶
func (p *RequestedPlugin) AutoLoaded() bool
func (*RequestedPlugin) Path ¶
func (p *RequestedPlugin) Path() string
func (*RequestedPlugin) ReadSignatureFile ¶
func (p *RequestedPlugin) ReadSignatureFile(file string) error
func (*RequestedPlugin) SetAutoLoaded ¶
func (p *RequestedPlugin) SetAutoLoaded(isAutoLoaded bool)
func (*RequestedPlugin) SetPath ¶
func (p *RequestedPlugin) SetPath(path string)
func (*RequestedPlugin) SetSignature ¶
func (p *RequestedPlugin) SetSignature(data []byte)
func (*RequestedPlugin) Signature ¶
func (p *RequestedPlugin) Signature() []byte
type SubscribedPlugin ¶
type SubscribedPlugin interface { Plugin Config() *cdata.ConfigDataNode }
type Task ¶
type Task interface { ID() string // Status() WorkflowState TODO, switch to string State() TaskState HitCount() uint GetName() string SetName(string) SetID(string) MissedCount() uint FailedCount() uint LastFailureMessage() string LastRunTime() *time.Time CreationTime() *time.Time DeadlineDuration() time.Duration SetDeadlineDuration(time.Duration) SetTaskID(id string) SetStopOnFailure(int) GetStopOnFailure() int Option(...TaskOption) TaskOption WMap() *wmap.WorkflowMap Schedule() schedule.Schedule }
func CreateTaskFromContent ¶
func CreateTaskFromContent(body io.ReadCloser, mode *bool, fp func(sch schedule.Schedule, wfMap *wmap.WorkflowMap, startOnCreate bool, opts ...TaskOption) (Task, TaskErrors)) (Task, error)
Function used to create a task according to content (1st parameter) . Content can be retrieved from a configuration file or a HTTP REST request body . Mode is used to specify if the created task should start right away or not . function pointer is responsible for effectively creating and returning the created task
type TaskCreationRequest ¶
type TaskCreationRequest struct { Name string `json:"name"` Version int `json:"version"` Deadline string `json:"deadline"` Workflow *wmap.WorkflowMap `json:"workflow"` Schedule *Schedule `json:"schedule"` Start bool `json:"start"` MaxFailures int `json:"max-failures"` }
func (*TaskCreationRequest) UnmarshalJSON ¶
func (tr *TaskCreationRequest) UnmarshalJSON(data []byte) error
type TaskErrors ¶
type TaskOption ¶
type TaskOption func(Task) TaskOption
func OptionStopOnFailure ¶
func OptionStopOnFailure(v int) TaskOption
TaskStopOnFailure sets the tasks stopOnFailure The stopOnFailure is the number of consecutive task failures that will trigger disabling the task
func SetTaskID ¶
func SetTaskID(id string) TaskOption
func SetTaskName ¶
func SetTaskName(name string) TaskOption
SetTaskName sets the name of the task. This is optional. If task name is not set, the task name is then defaulted to "Task-<task-id>"
func TaskDeadlineDuration ¶
func TaskDeadlineDuration(v time.Duration) TaskOption
TaskDeadlineDuration sets the tasks deadline. The deadline is the amount of time that can pass before a worker begins processing the tasks collect job.
type TaskWatcherCloser ¶
type TaskWatcherCloser interface {
Close() error
}
type TaskWatcherHandler ¶
type Workflow ¶
type Workflow interface { Marshal() ([]byte, error) Unmarshal([]byte) error State() WorkflowState }
type WorkflowState ¶
type WorkflowState int
const ( WorkflowStopped WorkflowState = iota WorkflowStarted )