Documentation ¶
Index ¶
- Constants
- func WrapContext(ctx context.Context, r *http.Request) context.Context
- type BackdateContextKey
- type Cluster
- type Index
- type IndexBlocker
- type IndexDumper
- type IndexInternalExpirerer
- type IndexRunner
- type IndexVerifier
- type LookupRequest
- type MetricData
- type MetricDataSet
- type MetricID
- type MetricLabel
- type MetricPoint
- func AddDuplicateForTest(input []MetricPoint, numberDuplicate int, rnd *rand.Rand) []MetricPoint
- func CopyPoints(points []MetricPoint) []MetricPoint
- func DeduplicatePoints(points []MetricPoint) []MetricPoint
- func MakePointsForTest(size int) []MetricPoint
- func MakePointsForTestOffset(size int, offsetMillisecond int64) []MetricPoint
- func ShuffleForTest(input []MetricPoint, rnd *rand.Rand) []MetricPoint
- type MetricReadWriter
- type MetricReader
- type MetricRequest
- type MetricWriter
- type MetricsSet
- type OldTask
- type RequestContextKey
- type State
- type Task
- type TaskFun
- type TryLocker
- type VerifiableIndex
Constants ¶
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 ¶
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 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 IndexRunner ¶
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 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 MetricLabel ¶
type MetricPoint ¶
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 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 ¶
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 Task ¶
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 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
}