mirror of https://github.com/tikv/client-go.git
add a function to set request source task type (#925)
* add a function to set request source task type Signed-off-by: glorv <glorvs@163.com>
This commit is contained in:
parent
a0d916d116
commit
300545a8a3
|
|
@ -48,10 +48,11 @@ const (
|
||||||
ExplicitTypeBR = "br"
|
ExplicitTypeBR = "br"
|
||||||
ExplicitTypeDumpling = "dumpling"
|
ExplicitTypeDumpling = "dumpling"
|
||||||
ExplicitTypeBackground = "background"
|
ExplicitTypeBackground = "background"
|
||||||
|
ExplicitTypeDDL = "ddl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExplicitTypeList is the list of all explicit source types.
|
// ExplicitTypeList is the list of all explicit source types.
|
||||||
var ExplicitTypeList = []string{ExplicitTypeEmpty, ExplicitTypeLightning, ExplicitTypeBR, ExplicitTypeDumpling, ExplicitTypeBackground}
|
var ExplicitTypeList = []string{ExplicitTypeEmpty, ExplicitTypeLightning, ExplicitTypeBR, ExplicitTypeDumpling, ExplicitTypeBackground, ExplicitTypeDDL}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// InternalRequest is the scope of internal queries
|
// InternalRequest is the scope of internal queries
|
||||||
|
|
@ -94,6 +95,15 @@ func WithInternalSourceType(ctx context.Context, source string) context.Context
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithInternalSourceAndTaskType create context with internal source and task name.
|
||||||
|
func WithInternalSourceAndTaskType(ctx context.Context, source, taskName string) context.Context {
|
||||||
|
return context.WithValue(ctx, RequestSourceKey, RequestSource{
|
||||||
|
RequestSourceInternal: true,
|
||||||
|
RequestSourceType: source,
|
||||||
|
ExplicitRequestSourceType: taskName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// BuildRequestSource builds a request_source from internal, source and explicitSource.
|
// BuildRequestSource builds a request_source from internal, source and explicitSource.
|
||||||
func BuildRequestSource(internal bool, source, explicitSource string) string {
|
func BuildRequestSource(internal bool, source, explicitSource string) string {
|
||||||
requestSource := RequestSource{
|
requestSource := RequestSource{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue