Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a function to set request source task type #925

Merged
merged 5 commits into from
Aug 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions util/request_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
ExplicitTypeBR = "br"
ExplicitTypeDumpling = "dumpling"
ExplicitTypeBackground = "background"
ExplicitTypeDDL = "ddl"
)

// ExplicitTypeList is the list of all explicit source types.
Expand Down Expand Up @@ -95,6 +96,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.
func BuildRequestSource(internal bool, source, explicitSource string) string {
requestSource := RequestSource{
Expand Down
Loading