query

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOrStaleView = errors.New("invalid or stale view")

ErrInvalidOrStaleView is returned when attempting to use wrong, stale, or cancelled view.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server                *connection.ServerConfig `mapstructure:"server"`
	Monitoring            monitoring.Config        `mapstructure:"monitoring"`
	Database              *vc.DatabaseConfig       `mapstructure:"database"`
	MinBatchKeys          int                      `mapstructure:"min-batch-keys"`
	MaxBatchWait          time.Duration            `mapstructure:"max-batch-wait"`
	ViewAggregationWindow time.Duration            `mapstructure:"view-aggregation-window"`
	MaxAggregatedViews    int                      `mapstructure:"max-aggregated-views"`
	MaxViewTimeout        time.Duration            `mapstructure:"max-view-timeout"`
}

Config is the configuration for the query service. To reduce the applied workload on the database and improve performance we batch views and queries. That is, views with the same protoqueryservice.ViewParameters will be batched together if they created within the ViewAggregationWindow. But no more than MaxAggregatedViews can be batched together. Queries from the same view and namespace will be batched together. A query batch is ready to be submitted if it has more keys than MinBatchKeys, or the batch has waited more than MaxBatchWait. Once a batch is ready, it is submitted as soon as there is a connection available, up the maximal number of connections defined in the Database configuration. Thus, a batch query can wait longer than MaxBatchWait if we don't have available connection. To avoid dangling views, a view is limited to a period of MaxViewTimeout. MaxViewTimeout includes the time it takes to execute the last query in the view. That is, if a query is executed while the timeout is expired, the query will be aborted. The number of parallel active views is theoretically unlimited as multiple views can be aggregated together. However, the number of active batched views is limited by the maximal number of database connections. Setting the maximal database connections higher than the following, ensures enough available connections. (MaxViewTimeout / ViewAggregationWindow) * <number-of-used-view-configuration-permutations> If there are no more available connections, queries will wait until such connection is available.

type Service

type Service struct {
	protoqueryservice.UnimplementedQueryServiceServer
	// contains filtered or unexported fields
}

Service is a gRPC service that implements the QueryServiceServer interface.

func NewQueryService

func NewQueryService(config *Config) *Service

NewQueryService create a new QueryService given a configuration.

func (*Service) BeginView

BeginView implements the query-service interface.

func (*Service) EndView

EndView implements the query-service interface.

func (*Service) GetConfigTransaction

func (q *Service) GetConfigTransaction(
	ctx context.Context,
	_ *emptypb.Empty,
) (*protoblocktx.ConfigTransaction, error)

GetConfigTransaction implements the query-service interface.

func (*Service) GetNamespacePolicies

func (q *Service) GetNamespacePolicies(
	ctx context.Context,
	_ *emptypb.Empty,
) (*protoblocktx.NamespacePolicies, error)

GetNamespacePolicies implements the query-service interface.

func (*Service) GetRows

func (q *Service) GetRows(
	ctx context.Context, query *protoqueryservice.Query,
) (*protoqueryservice.Rows, error)

GetRows implements the query-service interface.

func (*Service) RegisterService added in v0.1.5

func (q *Service) RegisterService(server *grpc.Server)

RegisterService registers for the query-service's GRPC services.

func (*Service) Run

func (q *Service) Run(ctx context.Context) error

Run starts the Prometheus server.

func (*Service) WaitForReady

func (q *Service) WaitForReady(ctx context.Context) bool

WaitForReady waits for the service resources to initialize, so it is ready to answers requests. If the context ended before the service is ready, returns false.

Jump to

Keyboard shortcuts

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