github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/ekv/variables.go (about)

     1  // Copyright 2020 WHTCORPS INC, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package ekv
    15  
    16  // Variables defines the variables used by KV storage.
    17  type Variables struct {
    18  	// BackoffLockFast specifies the LockFast backoff base duration in milliseconds.
    19  	BackoffLockFast int
    20  
    21  	// BackOffWeight specifies the weight of the max back off time duration.
    22  	BackOffWeight int
    23  
    24  	// Hook is used for test to verify the variable take effect.
    25  	Hook func(name string, vars *Variables)
    26  
    27  	// Pointer to StochastikVars.Killed
    28  	// Killed is a flag to indicate that this query is killed.
    29  	Killed *uint32
    30  }
    31  
    32  // NewVariables create a new Variables instance with default values.
    33  func NewVariables(killed *uint32) *Variables {
    34  	return &Variables{
    35  		BackoffLockFast: DefBackoffLockFast,
    36  		BackOffWeight:   DefBackOffWeight,
    37  		Killed:          killed,
    38  	}
    39  }
    40  
    41  var ignoreKill uint32
    42  
    43  // DefaultVars is the default variables instance.
    44  var DefaultVars = NewVariables(&ignoreKill)
    45  
    46  // Default values
    47  const (
    48  	DefBackoffLockFast = 100
    49  	DefBackOffWeight   = 2
    50  )