Documentation ¶
Index ¶
- Constants
- Variables
- func CloseTiDBConnection(db *gorm.DB) error
- func DownloadByToken(token, tokenNamespace string, c *gin.Context)
- func ExportCSV(data [][]string, filename, tokenNamespace string) (token string, err error)
- func GenerateBinaryPlan(v string) (*tipb.ExplainData, error)
- func GenerateBinaryPlanJSON(b string) (string, error)
- func GenerateBinaryPlanText(db *gorm.DB, b string) (string, error)
- func GenerateCSVFromRaw(rawData []interface{}, fields []string, timeFields []string) (data [][]string)
- func GetGormColumnName(gormStr string) string
- func GetTiDBConnection(c *gin.Context) *gorm.DB
- func IsSubsetICaseInsensitive(a []string, b []string) bool
- func MWConnectTiDB(tidbClient *tidb.Client) gin.HandlerFunc
- func MWForbidByExperimentalFlag(enableExp bool) gin.HandlerFunc
- func NewJWTString(issuer string, data string) (string, error)
- func NewJWTStringWithExpire(issuer string, data string, expireIn time.Duration) (string, error)
- func ParseJWTString(requiredIssuer string, tokenStr string) (string, error)
- func TakeTiDBConnection(c *gin.Context) *gorm.DB
- type AuthType
- type Claims
- type NgmProxy
- type NgmState
- type SessionUser
Constants ¶
const ( MainTree = "main" CteTrees = "ctes" Children = "children" Duration = "duration" Time = "time" Diagnosis = "diagnosis" RootGroupExecInfo = "rootGroupExecInfo" RootBasicExecInfo = "rootBasicExecInfo" OperatorInfo = "operatorInfo" OperatorName = "name" CopExecInfo = "copExecInfo" CacheHitRatio = "cacheHitRatio" TaskType = "taskType" StoreType = "storeType" DiskBytes = "diskBytes" MemoryBytes = "memoryBytes" ActRows = "actRows" EstRows = "estRows" AccessObjects = "accessObjects" ScanObject = "scanObject" DynamicpartitionObjects = "dynamicpartitionObjects" OtherObject = "otherObject" DiscardedDueToTooLong = "discardedDueToTooLong" BuildSide = "buildSide" ProbeSide = "probeSide" JoinTaskThreshold = 10000 // role tag. HighEstError = "high_est_error" DiskSpill = "disk_spill" PseudoEst = "pseudo_est" GoodFilterOnTableFullScan = "good_filter_on_table_fullscan" BadIndexForIndexLookUp = "bad_index_for_index_lookup" IndexJoinBuildSideTooLarge = "index_join_build_side_too_large" TiKVHugeTableScan = "tikv_huge_table_scan" )
const ( Default operator = iota IndexJoin IndexMergeJoin IndexHashJoin Apply Shuffle ShuffleReceiver IndexLookUpReader IndexMergeReader IndexFullScan IndexRangeScan TableFullScan TableRangeScan TableRowIDScan Selection )
const (
// The key that attached the SessionUser in the gin Context.
SessionUserKey = "user"
)
const SessionVersion = 2
Variables ¶
var ( NgmErrNS = errorx.NewNamespace("ngm") ErrNgmNotStart = NgmErrNS.NewType("ngm_not_started") )
var ErrExpNotEnabled = ErrNS.NewType("experimental_feature_not_enabled")
var ErrNS = errorx.NewNamespace("error.api")
Functions ¶
func CloseTiDBConnection ¶
func DownloadByToken ¶
FIXME: Remove or refine this function, as it is not general.
func GenerateBinaryPlan ¶
GenerateBinaryPlan generate visual plan from raw data.
func GenerateBinaryPlanJSON ¶
func GenerateCSVFromRaw ¶
func GenerateCSVFromRaw(rawData []interface{}, fields []string, timeFields []string) (data [][]string)
TODO: Better to be a streaming interface.
func GetGormColumnName ¶
func GetTiDBConnection ¶
GetTiDBConnection gets the TiDB connection stored in the gin context by `MWConnectTiDB` middleware.
The connection will be closed automatically after all handlers are finished. Thus you must not use it outside the request lifetime. If you want to extend the lifetime, use `TakeTiDBConnection`.
func MWConnectTiDB ¶
func MWConnectTiDB(tidbClient *tidb.Client) gin.HandlerFunc
MWConnectTiDB creates a middleware that attaches TiDB connection to the context, according to the identity information attached in the context. If a connection cannot be established, subsequent handlers will be skipped and errors will be generated.
This middleware must be placed after the `MWAuthRequired()` middleware, otherwise it will panic.
func MWForbidByExperimentalFlag ¶
func MWForbidByExperimentalFlag(enableExp bool) gin.HandlerFunc
func NewJWTString ¶
NewJWTString create a JWT string by given data, expire in 24 hours.
func NewJWTStringWithExpire ¶
func ParseJWTString ¶
ParseJWTString parse the JWT string and return the raw data.
func TakeTiDBConnection ¶
TakeTiDBConnection takes out the TiDB connection stored in the gin context by `MWConnectTiDB` middleware. Subsequent handlers in this context cannot access the TiDB connection any more.
The TiDB connection will no longer be closed automatically after all handlers are finished. You must manually close the taken out connection.
Types ¶
type Claims ¶
type Claims struct { Data string `json:"data"` jwt.StandardClaims }
Claims is a struct that will be encoded to a JWT.
type NgmProxy ¶
type NgmProxy struct {
// contains filtered or unexported fields
}
func NewNgmProxy ¶
type SessionUser ¶
type SessionUser struct { // Must be 2. This field is used to invalidate outdated sessions after schema change. Version int DisplayName string HasTiDBAuth bool TiDBUsername string TiDBPassword string SharedSessionExpireAt time.Time `msgpack:"-" json:",omitempty"` // This field only exists for SSOAuth OIDCIDToken string `json:",omitempty"` // These fields should not be updated by individual authenticators. AuthFrom AuthType `msgpack:"-" json:",omitempty"` // TODO: Make them table fields IsWriteable bool }
The content of this structure will be encrypted and stored as both Session Token and Sharing Token. For fields that don't need to be cloned during session sharing, mark fields as `msgpack:"-"`.
func GetSession ¶
func GetSession(c *gin.Context) *SessionUser