types

package
v0.0.0-...-2a93a25 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Add one matcher to limit the evaluated series.
	HeaderForcedMatcher = "X-SquirrelDB-Forced-Matcher"
	// Limit the number of series that can be evaluated by a request.
	// A limit of 0 means unlimited.
	HeaderMaxEvaluatedSeries = "X-SquirrelDB-Max-Evaluated-Series"
	// Limit the number of points that can be evaluated by a request.
	// A limit of 0 means unlimited.
	HeaderMaxEvaluatedPoints = "X-SquirrelDB-Max-Evaluated-Points"
	// Force using pre-aggregated data instead of raw points. Default for
	// query is raw data. Default for query_range depends on step value.
	HeaderForcePreAggregated = "X-SquirrelDB-ForcePreAggregated"
	// Force using raw data instead of pre-aggregated points. If both ForcePreAggregated
	// and ForceRaw are true, ForceRaw has priority. Default for query is raw data.
	// Default for query_range depends on step value.
	HeaderForceRaw = "X-SquirrelDB-ForceRaw"
	// Only match metrics from this tenant. Metrics written with this header
	// are associated to this tenant (a tenant label is added to the metric labels).
	HeaderTenant = "X-SquirrelDB-Tenant"
	// Set the metric Time To Live when writing.
	HeaderTimeToLive = "X-SquirrelDB-TTL"
	// Enable debugging information printed in SquirrelDB server log about a query.
	HeaderQueryDebug        = "X-SquirrelDB-Query-Debug"
	HeaderQueryVerboseDebug = "X-SquirrelDB-Query-Verbose-Debug"
)

HTTP headers available to dynamically change settings on PromQL and remote read.

Variables

This section is empty.

Functions

func WrapContext

func WrapContext(ctx context.Context, r *http.Request) context.Context

WrapContext adds a request to the context.

Types

type BackdateContextKey

type BackdateContextKey struct{}

BackdateContextKey is used as a key in a context to a points backdate offset.

type Cluster

type Cluster interface {
	// Publish sends a message that will be received by all subscribed nodes including sender.
	Publish(ctx context.Context, topic string, message []byte) error
	Subscribe(topic string, callback func([]byte))
	// Size returns the size of the cluster, including *this* SquirrelDB.
	Size() int
	Close() error
}

type Index

type Index interface {
	AllIDs(ctx context.Context, start time.Time, end time.Time) ([]MetricID, error)
	LookupIDs(ctx context.Context, requests []LookupRequest) ([]MetricID, []int64, error)
	Search(ctx context.Context, start time.Time, end time.Time, matchers []*labels.Matcher) (MetricsSet, error)
	LabelValues(ctx context.Context, start, end time.Time, name string, matchers []*labels.Matcher) ([]string, error)
	LabelNames(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) ([]string, error)
}

type IndexBlocker

type IndexBlocker interface {
	BlockCassandraWrite(ctx context.Context) error
	UnblockCassandraWrite(ctx context.Context) error
}

type IndexDumper

type IndexDumper interface {
	InfoGlobal(ctx context.Context, w io.Writer) error
	InfoByID(ctx context.Context, w io.Writer, id MetricID) error
	Dump(ctx context.Context, w io.Writer) error
	DumpByLabels(ctx context.Context, w io.Writer, start, end time.Time, matchers []*labels.Matcher) error
	DumpByExpirationDate(ctx context.Context, w io.Writer, expirationDate time.Time) error
	DumpByShard(ctx context.Context, w io.Writer, shard time.Time) error
	DumpByPosting(ctx context.Context, w io.Writer, shard time.Time, name string, value string) error
}

type IndexInternalExpirerer

type IndexInternalExpirerer interface {
	InternalForceExpirationTimestamp(ctx context.Context, value time.Time) error
}

type IndexRunner

type IndexRunner interface {
	InternalRunOnce(ctx context.Context, now time.Time) bool
}

type IndexVerifier

type IndexVerifier interface {
	WithNow(now time.Time) IndexVerifier
	WithDoFix(enable bool) IndexVerifier
	WithLock(enable bool) IndexVerifier
	WithStrictExpiration(enable bool) IndexVerifier
	WithStrictMetricCreation(enable bool) IndexVerifier
	WithPedanticExpiration(enable bool) IndexVerifier
	Verify(ctx context.Context) (hadIssue bool, err error)
}

type LookupRequest

type LookupRequest struct {
	Start      time.Time
	End        time.Time
	Labels     labels.Labels
	TTLSeconds int64
}

type MetricData

type MetricData struct {
	Points     []MetricPoint
	ID         MetricID
	TimeToLive int64
}

func MakeMetricDataForTest

func MakeMetricDataForTest(countMetric int, countPoints int, offsetMillisecond int64) []MetricData

MakeMetricDataForTest generate a list a MetricData for testing.

func MetricIterToList

func MetricIterToList(i MetricDataSet, numberOfNextCall int) ([]MetricData, error)

MetricIterToList convert a MetricDataSet to a list of MetricData. numberOfNextCall define the maximum number of call done to Next(). 0 means unlimited.

type MetricDataSet

type MetricDataSet interface {
	Next() bool
	At() MetricData
	Err() error
}

func MetricIterFromList

func MetricIterFromList(input []MetricData) MetricDataSet

type MetricID

type MetricID int64

type MetricLabel

type MetricLabel struct {
	Labels labels.Labels
	ID     MetricID
}

type MetricPoint

type MetricPoint struct {
	Timestamp int64
	Value     float64
}

func AddDuplicateForTest

func AddDuplicateForTest(input []MetricPoint, numberDuplicate int, rnd *rand.Rand) []MetricPoint

AddDuplicateForTest add duplicate points to a list of MetricPoint for testing.

func CopyPoints

func CopyPoints(points []MetricPoint) []MetricPoint

CopyPoints returns a copy of points.

func DeduplicatePoints

func DeduplicatePoints(points []MetricPoint) []MetricPoint

DeduplicatePoints returns the MetricPoint list deduplicated and sorted by timestamp.

func MakePointsForTest

func MakePointsForTest(size int) []MetricPoint

MakePointsForTest generate a list a MetricPoint for testing It generate point from timestamp Tue Sep 17 07:42:44 UTC 2019 with 10 seconds between each points.

func MakePointsForTestOffset

func MakePointsForTestOffset(size int, offsetMillisecond int64) []MetricPoint

MakePointsForTestOffset is like MakePointsForTest but include a timestamp offset.

func ShuffleForTest

func ShuffleForTest(input []MetricPoint, rnd *rand.Rand) []MetricPoint

ShuffleForTest shuffle a list of MetricPoint for testing.

type MetricReadWriter

type MetricReadWriter interface {
	MetricReader
	MetricWriter
}

type MetricReader

type MetricReader interface {
	ReadIter(ctx context.Context, request MetricRequest) (MetricDataSet, error)
}

type MetricRequest

type MetricRequest struct {
	Function           string
	IDs                []MetricID
	FromTimestamp      int64
	ToTimestamp        int64
	ForcePreAggregated bool
	ForceRaw           bool
	StepMs             int64
	EnableDebug        bool
	EnableVerboseDebug bool
}

type MetricWriter

type MetricWriter interface {
	Write(ctx context.Context, metrics []MetricData) error
}

type MetricsSet

type MetricsSet interface {
	Next() bool
	At() MetricLabel
	Err() error
	Count() int
}

type OldTask

type OldTask interface {
	Run(ctx context.Context, readiness chan error)
}

OldTask is a background worker that will be running until ctx is canceled. If readiness is not nil, when ready the task send one nil. If an error occurs, the task will send the error on the channel and return. You are not allowed to re-call Run() if an error is returned.

type RequestContextKey

type RequestContextKey struct{}

RequestContextKey is used as a key in a context to an HTTP request.

type State

type State interface {
	Read(ctx context.Context, name string, value interface{}) (bool, error)
	Write(ctx context.Context, name string, value interface{}) error
}

type Task

type Task interface {
	Start(ctx context.Context) error
	Stop() error
}

Task is a background worker that will be running until Stop() is called If Start() fail, the worker isn't running, but Start() could be retried. Start() called after worker is running and will do nothing and return nil. Stop() will shutdown and wait for shutdown before returning. Start() & Stop() can be called concurrently. The context for Start() should only be used for start itself. The worker will continue to run even if context is cancelled.

type TaskFun

type TaskFun func(ctx context.Context, readiness chan error)

func (TaskFun) Run

func (f TaskFun) Run(ctx context.Context, readiness chan error)

type TryLocker

type TryLocker interface {
	sync.Locker

	// TryLock try to acquire a lock but return false if unable to acquire it.
	TryLock(ctx context.Context, retryDelay time.Duration) bool
	BlockLock(ctx context.Context, blockTTL time.Duration) error
	UnblockLock(ctx context.Context) error
	BlockStatus(ctx context.Context) (bool, time.Duration, error)
}

TryLocker is a Locker with an additional TryLock() method and blocking methods.

type VerifiableIndex

type VerifiableIndex interface {
	Verifier(w io.Writer) IndexVerifier
}

Jump to

Keyboard shortcuts

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