types

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExpectControlType = "control-message"

	ControlMessageEndEvent         = "END_OF_CHANNEL"
	ControlMessageAbortEvent       = "ABORT_CHANNEL"
	ControlMessageStartStreamEvent = "STREAM_START"
)
View Source
const (
	ExeceptedKeepAliveEvent = "KEEP_ALIVE"
)
View Source
const ExpectedGeneralMessageType = "message"
View Source
const ExpectedMetadataType = "metadata"

Variables

View Source
var (
	// ErrNoDetectorFound is return when no valid detector is given
	ErrNoDetectorFound = errors.New("no detector passed")

	ErrAPIIssue = errors.New("unable to process request")

	ErrNotImplemented = errors.New("currently not implemented")

	ErrMissingClient = errors.New("missing required client")

	ErrFailedAuth = errors.New("failed auth")
)
View Source
var (
	// Endian is being cached within this package as the default Endian type to use when processing binary requests
	Endian = binary.BigEndian
)

Functions

func IsEndofMessages

func IsEndofMessages(msg *ControlMessage) bool

func IsWebsocketError

func IsWebsocketError(err error) bool

Types

type ControlMessage

type ControlMessage struct {
	Event       string `json:"event"`
	Kind        string `json:"type"`
	Channel     string `json:"channel"`
	TimestampMS int64  `json:"timestamp"`
	Progress    int    `json:"progress,omitempty`
}

func ReadControlMessage

func ReadControlMessage(data []byte) *ControlMessage

type Data

type Data struct {
	Version      uint8  `json:"version,omitempty"`
	TimeSeriesID string `json:"tsId"`
	// Value represents either a float32, int32 or nil
	Value interface{} `json:"value"`
}

Data represents a singular value

type Detector

type Detector struct {
	ID            string `json:"id"`
	Created       int64  `json:"created"`
	LastUpdated   int64  `json:"lastUpdated"`
	Creator       string `json:"creator"`
	LastUpdatedBy string `json:"lastUpdatedBy"`

	CustomProperties map[string]interface{} `json:"customProperties"`
	Locked           bool                   `json:"locked"`
	LabelResolutions map[string]int64       `json:"labelResolution"`
	MaxDelay         int32                  `json:"maxDelay"`
	OverMTSLimit     bool                   `json:"overMTSLimit"`
	Timezone         string                 `json:"timezone"`

	Name                 string        `json:"name"`
	Description          string        `json:"description"`
	Teams                []string      `json:"teams"`
	Tags                 []string      `json:"tags"`
	ProgramText          string        `json:"programText"`
	Rules                []Rule        `json:"rules"`
	VisualizationOptions Visualization `json:"visualizationOptions"`
}

Detector defines the response object from the SignalFx API for further details, check: https://developers.signalfx.com/detectors_reference.html

type Incident

type Incident struct{}

type Issue

type Issue int8

Issue is used as an enum value

const (
	// OK is used when no issue is detected
	OK Issue = iota + 1
	// System is used when the issue relates to an issue with SignalFx
	System
	// User is used when the issue relates to an issue that is result of user action
	User
	// Informational is used when as guide to highlight potential issue
	Informational
)

func (Issue) String

func (i Issue) String() string

type Message

type Message interface {
	GetType() string
}

Message defines the generic result returned back from the websocket connection

type MessageGeneral

type MessageGeneral struct {
	Kind               string                 `json:"type"`
	Channel            string                 `json:"channel"`
	LogicalTimeStampMs int64                  `json:"logicalTimestampMs"`
	Message            map[string]interface{} `json:"message"`
}

func ReadGeneralMessage

func ReadGeneralMessage(data []byte) *MessageGeneral

func (*MessageGeneral) GetType

func (gen *MessageGeneral) GetType() string

type MessageKeepAlive

type MessageKeepAlive struct {
	Event       string `json:"event"`
	TimestampMS int64  `json:"timestampMs"`
}

func ReadKeepAliveMessage

func ReadKeepAliveMessage(data []byte) *MessageKeepAlive

type MessageMetadata

type MessageMetadata struct {
	TimeSeriesID string                 `json:"tsId"`
	Kind         string                 `json:"type"`
	Properties   map[string]interface{} `json:"properties"`
	Channel      string                 `json:"channel"`
}

func ReadMetadataMessage

func ReadMetadataMessage(data []byte) *MessageMetadata

func (*MessageMetadata) GetType

func (meta *MessageMetadata) GetType() string

type MetricDataPoint

type MetricDataPoint struct {
	Version            int8    `json:"-"`
	Mtype              int8    `json:"-"`
	Flags              int8    `json:"-"`
	Channel            string  `json:"channel"`
	Kind               string  `json:"type"`
	LogicalTimestampMs int64   `json:"logicalTimestampMs"`
	MaxDelayMs         int64   `json:"maxDelayMs"`
	Data               []*Data `json:"data"`
}

MetricDataPoint contains all the values needed for a collection of datapoints

func ReadMetricDataPoint

func ReadMetricDataPoint(bin []byte) (*MetricDataPoint, error)

ReadMetricDataPoint reads a binary message from a websocket response and then will convert into a strong golang type

type QueryResults

type QueryResults struct {
	Count   int32             `json:"count"`
	Results []json.RawMessage `json:"results"`
}

QueryResults defines the abstracted bulk return from SignalFx when asking for items in bulk, the results field is left as json.RawMessages to allow for partial proccessing

type Result

type Result struct {
	IssueType Issue  `json:"issueType"`
	Tested    string `json:"tested"`
	Msg       string `json:"message"`
}

Result used when evaluation a known condition for a detector to be in an errored state

func CheckInformational

func CheckInformational(ok bool, tested string) *Result

func CheckSystemIssue

func CheckSystemIssue(ok bool, tested string) *Result

CheckSystemIssue is a convience function to return a SystemIssue iff ok is false

func CheckUserIssue

func CheckUserIssue(ok bool, tested string) *Result

CheckUserIssue is convience function to return an UserIssue iff ok is false

func InformationalIssue

func InformationalIssue(tested string) *Result

InformationalIssue returns a result is meant as an informative piece

func NoIssue

func NoIssue(tested string) *Result

NoIssue returns a Result with its IssueType set as OK and default message

func SystemIssue

func SystemIssue(tested string) *Result

SystemIssue returns a Result with its IssueType set as System and a default message

func UserIssue

func UserIssue(tested string) *Result

UserIssue returns a Result with its IssueType set as User and a default message

func (*Result) WithMessage

func (r *Result) WithMessage(msg string) *Result

WithMessage updates the Result's message and returns a deepcopy instead of modifying the orginal result

type Rule

type Rule struct {
	Description          string              `json:"description"`
	DetectLabel          string              `json:"detectLabel"`
	Disabled             bool                `json:"disabled"`
	Notifications        []map[string]string `json:"notifications,omitempty"`
	ParameterizedBody    string              `json:"parameterizedBody,omitempty"`
	ParameterizedSubject string              `json:"parameterizedSubject,omitempty"`
	RunbookURL           string              `json:"runbookUrl,omitempty"`
	Severity             string              `json:"severity"`
	Tip                  string              `json:"tip,omitempty"`
}

Rule defines the response object from the SignalFx API

type Time

type Time struct {
	Start int64  `json:"start"`
	End   int64  `json:"end"`
	Range int64  `json:"range"`
	Type  string `json:"type"`
}

Time defines the response object from the SignalFx API to be used with Detectors

type Visualization

type Visualization struct {
	DisableSampling     bool          `json:"disableSampling"`
	PublishLabelOptions []interface{} `json:"publishLabelOptions"`
	ShowDataMarkers     bool          `json:"showDataMarkers"`
	ShowEventLines      bool          `json:"showEventLines"`
	Time                Time          `json:"time"`
}

Visualization defines the response object from the SignalFx API

type WebsocketError

type WebsocketError struct {
	ErrorCode int                    `json:"error"`
	ErrorType string                 `json:"errorType"`
	Message   string                 `json:"message"`
	Channel   string                 `json:"channel"`
	Context   map[string]interface{} `json:"context"`
	Kind      string                 `json:"type"`
}

func ReadWebsocketError

func ReadWebsocketError(data []byte) *WebsocketError

func (*WebsocketError) Error

func (web *WebsocketError) Error() string

Jump to

Keyboard shortcuts

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