Documentation
¶
Index ¶
- Variables
- type Config
- type Service
- func (q *Service) BeginView(ctx context.Context, params *protoqueryservice.ViewParameters) (*protoqueryservice.View, error)
- func (q *Service) EndView(_ context.Context, view *protoqueryservice.View) (*protoqueryservice.View, error)
- func (q *Service) GetConfigTransaction(ctx context.Context, _ *emptypb.Empty) (*protoblocktx.ConfigTransaction, error)
- func (q *Service) GetNamespacePolicies(ctx context.Context, _ *emptypb.Empty) (*protoblocktx.NamespacePolicies, error)
- func (q *Service) GetRows(ctx context.Context, query *protoqueryservice.Query) (*protoqueryservice.Rows, 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 = 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 ¶
NewQueryService create a new QueryService given a configuration.
func (*Service) BeginView ¶
func (q *Service) BeginView( ctx context.Context, params *protoqueryservice.ViewParameters, ) (*protoqueryservice.View, error)
BeginView implements the query-service interface.
func (*Service) EndView ¶
func (q *Service) EndView( _ context.Context, view *protoqueryservice.View, ) (*protoqueryservice.View, error)
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
RegisterService registers for the query-service's GRPC services.