common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package common defines reusable objects for APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// FlagNodeHost is the node id from flag.
	FlagNodeHost string
	// FlagNodeHostProvider is the node id provider from flag.
	FlagNodeHostProvider NodeHostProvider
)
View Source
var ContextNodeKey = contextNodeKey{}

ContextNodeKey is a context key to store the node id.

View Source
var ContextNodeRolesKey = contextNodeRolesKey{}

ContextNodeRolesKey is a context key to store the node roles.

Functions

func LabelNames added in v0.4.0

func LabelNames() []string

LabelNames returns the label names of Position.

func SetPosition

func SetPosition(ctx context.Context, fn func(p Position) Position) context.Context

SetPosition sets a position returned from fn to attach it to ctx, then return a new context.

func ShardLabelNames added in v0.4.0

func ShardLabelNames() []string

ShardLabelNames returns the label names of Position. It is used for shard level metrics.

Types

type Error added in v0.2.0

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

Error wraps a error msg.

func NewError added in v0.2.0

func NewError(tpl string, args ...any) Error

NewError returns a new Error.

func (Error) Msg added in v0.2.0

func (e Error) Msg() string

Msg shows the string msg.

type ItemID

type ItemID uint64

ItemID identities an item in a series.

type KindVersion

type KindVersion struct {
	Version string
	Kind    string
}

KindVersion contains elements which identify the API uniquely.

func (*KindVersion) String

func (s *KindVersion) String() string

type Node added in v0.5.0

type Node struct {
	NodeID      string
	GrpcAddress string
	HTTPAddress string
}

Node contains the node id and address.

func GenerateNode added in v0.5.0

func GenerateNode(grpcPort, httpPort *uint32) (Node, error)

GenerateNode generates a node id.

type NodeHostProvider added in v0.5.0

type NodeHostProvider int

NodeHostProvider is the provider of node id.

const (
	NodeHostProviderHostname NodeHostProvider = iota
	NodeHostProviderIP
	NodeHostProviderFlag
)

NodeIDProvider constants.

func ParseNodeHostProvider added in v0.5.0

func ParseNodeHostProvider(s string) (NodeHostProvider, error)

ParseNodeHostProvider parses the string to NodeIDProvider.

func (*NodeHostProvider) String added in v0.5.0

func (n *NodeHostProvider) String() string

String returns the string representation of NodeIDProvider.

type Position

type Position struct {
	Module   string
	Database string
	Shard    string
	Segment  string
	Block    string
}

Position is stored in the context. The logger could attach it for debugging.

func GetPosition added in v0.4.0

func GetPosition(ctx context.Context) Position

GetPosition returns the position from ctx.

func (Position) LabelValues added in v0.4.0

func (p Position) LabelValues() []string

LabelValues returns the label values of Position.

func (Position) ShardLabelValues added in v0.4.0

func (p Position) ShardLabelValues() []string

ShardLabelValues returns the label values of Position. It is used for shard level metrics.

type SeriesID

type SeriesID uint64

SeriesID identities a series in a shard.

func (SeriesID) Marshal

func (s SeriesID) Marshal() []byte

Marshal encodes series id to bytes.

type ShardID

type ShardID uint32

ShardID identities a shard in a tsdb.

Jump to

Keyboard shortcuts

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