readpath

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoV2Data = errors.New("no v2 data ingested for tenant")

Functions

func Query

func Query[Req, Resp any](
	ctx context.Context,
	router *Router,
	req *connect.Request[Req],
	sanitize func(a, b *Req),
	aggregate func(a, b *Resp) (*Resp, error),
) (*connect.Response[Resp], error)

Query routes a query to the appropriate query frontend. Before the call to the frontend is made, the requests are sanitized: any of the arguments can be nil, but not both. If the query was split, the responses are aggregated.

Types

type Config

type Config struct {
	EnableQueryBackend     bool             `yaml:"enable_query_backend" json:"enable_query_backend" category:"advanced" doc:"hidden"`
	EnableQueryBackendFrom QueryBackendFrom `yaml:"enable_query_backend_from" json:"enable_query_backend_from" doc:"hidden"`
	QueryTreeEnabled       bool             `yaml:"query_tree_enabled" json:"query_tree_enabled" category:"experimental" doc:"hidden"`
}

func (*Config) RegisterFlags

func (o *Config) RegisterFlags(f *flag.FlagSet)

type MetastoreSplitTimeResolver

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

MetastoreSplitTimeResolver resolves the split time for "auto" mode by querying the metastore for each tenant's oldest profile time. Results are cached per tenant to avoid calling the metastore on every query.

func NewMetastoreSplitTimeResolver

func NewMetastoreSplitTimeResolver(client TenantServiceClient, ttl time.Duration) *MetastoreSplitTimeResolver

func (*MetastoreSplitTimeResolver) OldestProfileTime

func (r *MetastoreSplitTimeResolver) OldestProfileTime(ctx context.Context, tenantID string) (time.Time, error)

type Overrides

type Overrides interface {
	ReadPathOverrides(tenantID string) Config
}

type QueryBackendFrom

type QueryBackendFrom struct {
	Auto bool
	Time time.Time
}

QueryBackendFrom is a flag/config type that accepts either an RFC3339 timestamp or the special value "auto". When set to "auto", the split point is resolved at query time by looking up the tenant's oldest profile time in the metastore.

func (QueryBackendFrom) IsZero

func (q QueryBackendFrom) IsZero() bool

func (QueryBackendFrom) MarshalJSON

func (q QueryBackendFrom) MarshalJSON() ([]byte, error)

func (QueryBackendFrom) MarshalText

func (q QueryBackendFrom) MarshalText() ([]byte, error)

func (QueryBackendFrom) MarshalYAML

func (q QueryBackendFrom) MarshalYAML() (interface{}, error)

func (*QueryBackendFrom) Set

func (q *QueryBackendFrom) Set(s string) error

Set implements flag.Value.

func (QueryBackendFrom) SplitTime

func (q QueryBackendFrom) SplitTime(tenantOldestProfileTime func() (time.Time, error)) (time.Time, error)

SplitTime returns the split timestamp for routing queries. For a fixed timestamp, it returns the time directly. For "auto" mode, it queries the metastore for the tenant's oldest profile time. Returns zero time if the split cannot be determined.

func (QueryBackendFrom) String

func (q QueryBackendFrom) String() string

String implements flag.Value.

func (*QueryBackendFrom) UnmarshalJSON

func (q *QueryBackendFrom) UnmarshalJSON(data []byte) error

func (*QueryBackendFrom) UnmarshalText

func (q *QueryBackendFrom) UnmarshalText(data []byte) error

func (*QueryBackendFrom) UnmarshalYAML

func (q *QueryBackendFrom) UnmarshalYAML(value *yaml.Node) error

type Router

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

Router is a proxy that routes queries to the query frontend.

If the query backend is enabled, it routes queries to the new query frontend, otherwise it routes queries to the old query frontend.

If the query targets a time range that spans the enablement of the new query backend, it splits the query into two parts and sends them to the old and new query frontends.

func NewRouter

func NewRouter(
	logger log.Logger,
	overrides Overrides,
	resolver SplitTimeResolver,
	oldFrontend querierv1connect.QuerierServiceClient,
	newFrontend querierv1connect.QuerierServiceClient,
) *Router

type SplitTimeResolver

type SplitTimeResolver interface {
	OldestProfileTime(ctx context.Context, tenantID string) (time.Time, error)
}

SplitTimeResolver resolves the split time for a tenant in "auto" mode. It returns the oldest profile time known for the tenant in the v2 storage.

type TenantServiceClient

type TenantServiceClient interface {
	GetTenant(ctx context.Context, in *metastorev1.GetTenantRequest, opts ...grpc.CallOption) (*metastorev1.GetTenantResponse, error)
}

TenantServiceClient is the subset of the metastore client needed to resolve the oldest profile time for a tenant.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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