Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
476 changes: 476 additions & 0 deletions go/vt/proto/querythrottler/querythrottler.pb.go

Large diffs are not rendered by default.

1,451 changes: 1,451 additions & 0 deletions go/vt/proto/querythrottler/querythrottler_vtproto.pb.go

Large diffs are not rendered by default.

96 changes: 60 additions & 36 deletions go/vt/proto/topodata/topodata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 111 additions & 0 deletions go/vt/proto/topodata/topodata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 28 additions & 6 deletions go/vt/vttablet/tabletserver/querythrottler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ limitations under the License.

package querythrottler

import "vitess.io/vitess/go/vt/vttablet/tabletserver/querythrottler/registry"
import (
querythrottlerpb "vitess.io/vitess/go/vt/proto/querythrottler"
"vitess.io/vitess/go/vt/vttablet/tabletserver/querythrottler/registry"
)

// Compile-time interface compliance check
var _ registry.StrategyConfig = (*Config)(nil)
Expand All @@ -32,11 +35,30 @@ type Config struct {
// throttling decision is logged for observability.
DryRun bool `json:"dry_run"`

// Strategy selects which throttling strategy should be used.
Strategy registry.ThrottlingStrategy `json:"strategy"`
// StrategyName name of the strategy to use for throttling.
StrategyName registry.ThrottlingStrategy `json:"strategy"`
}

// GetStrategy implements registry.StrategyConfig interface
func (c Config) GetStrategy() registry.ThrottlingStrategy {
return c.Strategy
// GetStrategyName implements registry.StrategyConfig interface
func (c Config) GetStrategyName() registry.ThrottlingStrategy {
return c.StrategyName
}

// ConfigFromProto converts a protobuf QueryThrottler configuration into its internal Config representation.
// It processes the incoming configuration and creates a complete Config struct with all necessary mappings for tablet rules, statement rules, and metric rules.
func ConfigFromProto(queryThrottlerConfig *querythrottlerpb.Config) Config {
return Config{
Enabled: queryThrottlerConfig.GetEnabled(),
DryRun: queryThrottlerConfig.GetDryRun(),
StrategyName: ThrottlingStrategyFromProto(queryThrottlerConfig.GetStrategy()),
}
}

func ThrottlingStrategyFromProto(strategy querythrottlerpb.ThrottlingStrategy) registry.ThrottlingStrategy {
switch strategy {
case querythrottlerpb.ThrottlingStrategy_TABLET_THROTTLER:
return registry.ThrottlingStrategyTabletThrottler
default:
return registry.ThrottlingStrategyUnknown
}
}
Loading
Loading