core

package
Version: v0.16.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 14 Imported by: 423

Documentation

Index

Constants

View Source
const (
	// Separator is the default separator used in strings
	Separator = "\U0001f422"
)

Variables

View Source
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")
)
View Source
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"
)
View Source
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 AvailablePlugin interface {
	Plugin
	HitCount() int
	LastHit() time.Time
	ID() uint32
}

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

func NewNamespace(ns ...string) Namespace

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

func (n Namespace) AddDynamicElement(name, description string) Namespace

AddDynamicElement adds a dynamic element to the given Namespace. A dynamic NamespaceElement is defined by having a nonempty Name field.

func (Namespace) AddStaticElement

func (n Namespace) AddStaticElement(value string) Namespace

AddStaticElement adds a static element to the given Namespace. A static NamespaceElement is defined by having an empty Name field.

func (Namespace) AddStaticElements

func (n Namespace) AddStaticElements(values ...string) Namespace

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

func (n Namespace) IsDynamic() (bool, []int)

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

func (n Namespace) Key() string

Key returns a string representation of the namespace with "." joining the elements of the namespace.

func (Namespace) String

func (n Namespace) String() string

String returns the string representation of the namespace with "/" joining the elements of the namespace. A leading "/" is added.

func (Namespace) Strings

func (n Namespace) Strings() []string

Strings returns an array of strings that represent the elements of the namespace.

type NamespaceElement

type NamespaceElement struct {
	Value       string
	Description string
	Name        string
}

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 Plugin

type Plugin interface {
	TypeName() string
	Name() string
	Version() int
}

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

type RequestedMetric interface {
	Namespace() Namespace
	Version() int
}

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) CheckSum

func (p *RequestedPlugin) CheckSum() [sha256.Size]byte

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 Schedule

type Schedule struct {
	Type           string `json:"type,omitempty"`
	Interval       string `json:"interval,omitempty"`
	StartTimestamp *int64 `json:"start_timestamp,omitempty"`
	StopTimestamp  *int64 `json:"stop_timestamp,omitempty"`
}

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 TaskErrors interface {
	Errors() []serror.SnapError
}

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 TaskState

type TaskState int
const (
	TaskDisabled TaskState = iota - 1
	TaskStopped
	TaskSpinning
	TaskFiring
	TaskEnded
	TaskStopping
)

func (TaskState) String

func (t TaskState) String() string

type TaskWatcherCloser

type TaskWatcherCloser interface {
	Close() error
}

type TaskWatcherHandler

type TaskWatcherHandler interface {
	CatchCollection([]Metric)
	CatchTaskStarted()
	CatchTaskStopped()
	CatchTaskDisabled(string)
}

type Workflow

type Workflow interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	State() WorkflowState
}

type WorkflowState

type WorkflowState int
const (
	WorkflowStopped WorkflowState = iota
	WorkflowStarted
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL