vitess.io/vitess@v0.16.2/go/vt/throttler/module.go (about)

     1  /*
     2  Copyright 2019 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package throttler
    18  
    19  // Module specifies the API for a Decision Module which can tell the throttler
    20  // to dynamically increase or decrease the current rate limit.
    21  type Module interface {
    22  	// Start can be implemented to e.g. start own Go routines and initialize the
    23  	// module.
    24  	// rateUpdateChan must be used to notify the Throttler when the module's
    25  	// maximum rate limit has changed and a subsequent MaxRate() call would return
    26  	// a different value.
    27  	Start(rateUpdateChan chan<- struct{})
    28  	// Stop will free all resources and be called by Throttler.Close().
    29  	Stop()
    30  
    31  	// MaxRate returns the maximum allowed rate determined by the module.
    32  	MaxRate() int64
    33  }