dummy

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMutableLabels = MutableLabels{
	AssociatedNames: map[string]map[string]string{
		"1234": {
			"group":       "instance",
			"environment": "instance",
		},
		"5678": {
			"group": "instance",
		},
	},
	AssociatedValues: map[mutable.LabelKey]map[string][]string{
		{
			Tenant: "1234",
			Name:   "group",
		}: {
			"group1": []string{"server1", "server2", "server3"},
			"group2": []string{"server2", "server3"},
			"group3": []string{"server4"},
		},
		{
			Tenant: "1234",
			Name:   "environment",
		}: {
			"prod": []string{"server4"},
		},
		{
			Tenant: "5678",
			Name:   "group",
		}: {
			"group10": []string{"server10", "server11"},
		},
	},
}

DefaultMutableLabels contains some mutable labels that can be used in tests.

Functions

func MetricsSetEqual

func MetricsSetEqual(a, b types.MetricsSet) bool

MetricsSetEqual tests if two MetricsSet contains the same list in the same order.

func NewMutableLabelStore

func NewMutableLabelStore(lbls MutableLabels) mutable.Store

NewMutableLabelStore returns a mock label store pre filled with labels.

Types

type DiscardTSDB

type DiscardTSDB struct{}

DiscardTSDB will write metrics to /dev/null.

func (DiscardTSDB) Flush

func (d DiscardTSDB) Flush()

func (DiscardTSDB) ReadIter

ReadIter return an empty result.

func (DiscardTSDB) Run

func (d DiscardTSDB) Run(ctx context.Context, readiness chan error)

func (DiscardTSDB) Write

func (d DiscardTSDB) Write(_ context.Context, _ []types.MetricData) error

Write discard metrics.

type Index

type Index struct {
	StoreMetricIDInMemory bool
	FixedValue            types.MetricID
	// contains filtered or unexported fields
}

Index implement a non-working index. It only useful for testing/benchmark. See each function for their limitation.

func NewIndex

func NewIndex(metrics []types.MetricLabel) *Index

NewIndex create a new index pre-filled with metrics.

func (*Index) AllIDs

func (idx *Index) AllIDs(ctx context.Context, _ time.Time, _ time.Time) ([]types.MetricID, error)

AllIDs does not store IDs in any persistent store. So this is lost after every restart. It may even not store them at all!

func (*Index) LabelNames

func (idx *Index) LabelNames(ctx context.Context, _, _ time.Time, matchers []*labels.Matcher) ([]string, error)

LabelNames only works when StoreMetricIDInMemory is enabled.

func (*Index) LabelValues

func (idx *Index) LabelValues(
	ctx context.Context,
	_, _ time.Time,
	name string,
	matchers []*labels.Matcher,
) ([]string, error)

LabelValues only works when StoreMetricIDInMemory is enabled.

func (*Index) LookupIDs

func (idx *Index) LookupIDs(ctx context.Context, requests []types.LookupRequest) ([]types.MetricID, []int64, error)

LookupIDs may have collision. If StoreMetricIDInMemory collision are checked (but not across restart).

func (*Index) Search

func (idx *Index) Search(
	ctx context.Context,
	_ time.Time,
	_ time.Time,
	matchers []*labels.Matcher,
) (types.MetricsSet, error)

Search only works when StoreMetricIDInMemory is enabled.

type LocalCluster

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

LocalCluster implement types.Cluster but only for clients sharing the same LocalCluster object.

func (*LocalCluster) Close

func (c *LocalCluster) Close() error

func (*LocalCluster) Publish

func (c *LocalCluster) Publish(_ context.Context, topic string, message []byte) error

func (*LocalCluster) Size

func (c *LocalCluster) Size() int

func (*LocalCluster) Subscribe

func (c *LocalCluster) Subscribe(topic string, callback func([]byte))

type Locks

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

Locks is a non-distributed lock factory. It should only be used for single-node.

func (*Locks) CreateLock

func (l *Locks) CreateLock(name string, _ time.Duration) types.TryLocker

CreateLock return a TryLocker for given name. This locker is NOT common across all SquirrelDB and not even this process. It's only common to this factory. timeToLive is ignored, as it normally only used in case of crash to release the lock.

type MemoryTSDB

type MemoryTSDB struct {
	Data       map[types.MetricID]types.MetricData
	LogRequest bool
	Reads      []types.MetricRequest
	Writes     [][]types.MetricData
	// contains filtered or unexported fields
}

MemoryTSDB store all value in memory. Only useful in unittest.

func (*MemoryTSDB) DumpData

func (db *MemoryTSDB) DumpData() []types.MetricData

DumpData dump to content of the TSDB. Result is ordered by MetricID.

func (*MemoryTSDB) ReadIter

func (db *MemoryTSDB) ReadIter(_ context.Context, request types.MetricRequest) (types.MetricDataSet, error)

ReadIter return an empty result.

func (*MemoryTSDB) Write

func (db *MemoryTSDB) Write(_ context.Context, metrics []types.MetricData) error

Write store in memory.

type MetricsLabel

type MetricsLabel struct {
	List []types.MetricLabel
	// contains filtered or unexported fields
}

func (*MetricsLabel) At

func (l *MetricsLabel) At() types.MetricLabel

func (*MetricsLabel) Count

func (l *MetricsLabel) Count() int

func (*MetricsLabel) Err

func (l *MetricsLabel) Err() error

func (*MetricsLabel) Next

func (l *MetricsLabel) Next() bool

type MutableLabels

type MutableLabels struct {
	// map[tenant][mutable label name] -> associated non mutable label name.
	AssociatedNames map[string]map[string]string
	// map[tenant, mutable label name][mutable label value] -> associated non mutable label values.
	AssociatedValues map[mutable.LabelKey]map[string][]string
}

MutableLabels stores all mutable labels in the dummy label provider.

type States

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

States is a in-memory single-node "states", that is a map :) Only useful for tests.

func (*States) Read

func (s *States) Read(_ context.Context, name string, value interface{}) (bool, error)

func (*States) Write

func (s *States) Write(_ context.Context, name string, value interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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