metric

package
v0.0.0-...-33bb219 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package metric defines things that we measure to determine how well a task is performing

Package metric implements the queue metric for NSQ (http://nsq.io/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcsInit

func AcsInit() (err error)

AcsInit sets up an Azure Client that can talk to the storage account

func NSQInit

func NSQInit()

NSQInit sets up the NSQ Stats endpoint.

Types

type AzureQueueMetric

type AzureQueueMetric struct {
	// contains filtered or unexported fields
}

AzureQueueMetric is used to measure the length of an Azure Storage Accout Queue

func NewAzureQueueMetric

func NewAzureQueueMetric(queueName string) *AzureQueueMetric

NewAzureQueueMetric makes sure we have access to the Azure client

func (*AzureQueueMetric) Current

func (aqm *AzureQueueMetric) Current() int

Current reads out the value of the current queue length

func (*AzureQueueMetric) UpdateCurrent

func (aqm *AzureQueueMetric) UpdateCurrent()

UpdateCurrent calls the Azure Storage API to get the queue length and stores the value in the metric.

type Channel

type Channel struct {
	ChannelName string `json:"channel_name"`
	Depth       int    `json:"depth"`
}

Channel from NSQ stats API.

type Metric

type Metric interface {
	UpdateCurrent()
	Current() int
}

Metric is something we measure. Each task is associated with a Metric and a Target that we want the Metric to stay close to.

type NSQMetric

type NSQMetric struct {
	// contains filtered or unexported fields
}

NSQMetric stores the current value.

func NewNSQMetric

func NewNSQMetric(topicName string, channelName string) *NSQMetric

NewNSQMetric creates the metric.

func (*NSQMetric) Current

func (nsqm *NSQMetric) Current() int

Current returns the queue length.

func (*NSQMetric) UpdateCurrent

func (nsqm *NSQMetric) UpdateCurrent()

UpdateCurrent sets the current queue length.

type NullMetric

type NullMetric struct{}

NullMetric for cases such as Remainder rules, where we don't need to actually measure a current value

func NewNullMetric

func NewNullMetric() *NullMetric

NewNullMetric creates a new Null metric

func (*NullMetric) Current

func (n *NullMetric) Current() int

Current reads out the value of the current queue length - which is always 0 for the Null metric

func (*NullMetric) UpdateCurrent

func (n *NullMetric) UpdateCurrent()

UpdateCurrent reads the value of the current metric, but this is a no-op for the Null metric

type SQSMetric

type SQSMetric struct {
	// contains filtered or unexported fields
}

SQSMetric is used to measure the length of an SQS Queue

func NewSQSMetric

func NewSQSMetric(queueURL string) (metric *SQSMetric, err error)

NewSQSMetric makes sure we have access to the SQS client

func (*SQSMetric) Current

func (sm *SQSMetric) Current() int

Current reads out the value of the current queue length

func (*SQSMetric) UpdateCurrent

func (sm *SQSMetric) UpdateCurrent()

UpdateCurrent calls the SQS API to get the queue length and stores the value in the metric.

type StatsData

type StatsData struct {
	Topics []Topic `json:"topics"`
}

StatsData from NSQ stats API.

type StatsMessage

type StatsMessage struct {
	Data StatsData `json:"data"`
}

StatsMessage from NSQ stats API.

type Topic

type Topic struct {
	TopicName string    `json:"topic_name"`
	Channels  []Channel `json:"channels"`
}

Topic from NSQ stats API.

type ToyMetric

type ToyMetric struct {
	SettableCurrent int
}

ToyMetric is only used for testing, but we can set its value

func NewToyMetric

func NewToyMetric() *ToyMetric

NewToyMetric creates a new toy metric

func (*ToyMetric) Current

func (t *ToyMetric) Current() int

Current reads out the value of the current queue length

func (*ToyMetric) UpdateCurrent

func (t *ToyMetric) UpdateCurrent()

UpdateCurrent reads the value of the current metric, but this is a no-op for the Toy metric

Jump to

Keyboard shortcuts

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