forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tablet throttler: inter-checks via gRPC (vitessio#13514)
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
- Loading branch information
1 parent
dcacec7
commit b065394
Showing
23 changed files
with
1,814 additions
and
198 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
419 changes: 419 additions & 0 deletions
419
go/vt/proto/tabletmanagerdata/tabletmanagerdata_vtproto.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
231 changes: 121 additions & 110 deletions
231
go/vt/proto/tabletmanagerservice/tabletmanagerservice.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
go/vt/proto/tabletmanagerservice/tabletmanagerservice_grpc.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
Copyright 2023 The Vitess Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package tabletmanager | ||
|
||
import ( | ||
"context" | ||
|
||
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" | ||
"vitess.io/vitess/go/vt/proto/vtrpc" | ||
"vitess.io/vitess/go/vt/vterrors" | ||
"vitess.io/vitess/go/vt/vttablet/tabletserver/throttle" | ||
"vitess.io/vitess/go/vt/vttablet/tabletserver/throttle/throttlerapp" | ||
) | ||
|
||
// CheckThrottler executes a throttler check | ||
func (tm *TabletManager) CheckThrottler(ctx context.Context, req *tabletmanagerdatapb.CheckThrottlerRequest) (*tabletmanagerdatapb.CheckThrottlerResponse, error) { | ||
if req.AppName == "" { | ||
req.AppName = throttlerapp.VitessName.String() | ||
} | ||
flags := &throttle.CheckFlags{ | ||
LowPriority: false, | ||
SkipRequestHeartbeats: true, | ||
} | ||
checkResult := tm.QueryServiceControl.CheckThrottler(ctx, req.AppName, flags) | ||
if checkResult == nil { | ||
return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "nil checkResult") | ||
} | ||
resp := &tabletmanagerdatapb.CheckThrottlerResponse{ | ||
StatusCode: int32(checkResult.StatusCode), | ||
Value: checkResult.Value, | ||
Threshold: checkResult.Threshold, | ||
Message: checkResult.Message, | ||
RecentlyChecked: checkResult.RecentlyChecked, | ||
} | ||
if checkResult.Error != nil { | ||
resp.Error = checkResult.Error.Error() | ||
} | ||
return resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.