Documentation
¶
Index ¶
- Variables
- type Config
- type Service
- func (q *Service) BeginView(ctx context.Context, params *committerpb.ViewParameters) (*committerpb.View, error)
- func (q *Service) EndView(_ context.Context, view *committerpb.View) (*emptypb.Empty, error)
- func (q *Service) GetConfigTransaction(ctx context.Context, _ *emptypb.Empty) (*applicationpb.ConfigTransaction, error)
- func (q *Service) GetNamespacePolicies(ctx context.Context, _ *emptypb.Empty) (*applicationpb.NamespacePolicies, error)
- func (q *Service) GetRows(ctx context.Context, query *committerpb.Query) (*committerpb.Rows, error)
- func (q *Service) GetTransactionStatus(ctx context.Context, query *committerpb.TxStatusQuery) (*committerpb.TxStatusResponse, error)
- func (q *Service) RegisterService(server *grpc.Server)
- func (q *Service) Run(ctx context.Context) error
- func (q *Service) WaitForReady(ctx context.Context) bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidOrStaleView is returned when attempting to use wrong, stale, or cancelled view. ErrInvalidOrStaleView = errors.New("invalid or stale view") // ErrTooManyKeys is returned when the number of keys in a request exceeds the configured limit. ErrTooManyKeys = errors.New("request exceeds maximum allowed keys") // ErrEmptyNamespaces is returned when a query request does not contain any namespaces. ErrEmptyNamespaces = errors.New("query namespaces must not be empty") // ErrEmptyKeys is returned when a namespace query does not contain any keys. ErrEmptyKeys = errors.New("query namespace keys must not be empty") // ErrEmptyTxIDs is returned when a transaction status query has no transaction IDs. ErrEmptyTxIDs = errors.New("transaction status query tx_ids must not be empty") // ErrTooManyActiveViews is returned when the number of active views exceeds the configured limit. ErrTooManyActiveViews = errors.New("active view limit exceeded") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Server *connection.ServerConfig `mapstructure:"server"`
Monitoring *connection.ServerConfig `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"`
MaxActiveViews int `mapstructure:"max-active-views"`
MaxViewTimeout time.Duration `mapstructure:"max-view-timeout"`
// MaxRequestKeys is the maximum number of keys allowed in a single query request.
// This applies to both GetRows (total keys across all namespaces) and
// GetTransactionStatus (number of transaction IDs).
// Set to 0 to disable the limit.
MaxRequestKeys int `mapstructure:"max-request-keys"`
}
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 {
committerpb.UnimplementedQueryServiceServer
// contains filtered or unexported fields
}
Service is a gRPC service that implements the QueryServiceServer interface.
func NewQueryService ¶
NewQueryService create a new QueryService given a configuration.
func (*Service) BeginView ¶
func (q *Service) BeginView( ctx context.Context, params *committerpb.ViewParameters, ) (*committerpb.View, error)
BeginView implements the query-service interface.
func (*Service) GetConfigTransaction ¶
func (q *Service) GetConfigTransaction( ctx context.Context, _ *emptypb.Empty, ) (*applicationpb.ConfigTransaction, error)
GetConfigTransaction implements the query-service interface.
func (*Service) GetNamespacePolicies ¶
func (q *Service) GetNamespacePolicies( ctx context.Context, _ *emptypb.Empty, ) (*applicationpb.NamespacePolicies, error)
GetNamespacePolicies implements the query-service interface.
func (*Service) GetRows ¶
func (q *Service) GetRows( ctx context.Context, query *committerpb.Query, ) (*committerpb.Rows, error)
GetRows implements the query-service interface.
func (*Service) GetTransactionStatus ¶ added in v0.1.7
func (q *Service) GetTransactionStatus( ctx context.Context, query *committerpb.TxStatusQuery, ) (*committerpb.TxStatusResponse, error)
GetTransactionStatus implements the query-service interface.
func (*Service) RegisterService ¶ added in v0.1.5
RegisterService registers for the query-service's GRPC services.