mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-14 09:01:16 +00:00
16 lines
516 B
Go
16 lines
516 B
Go
package github
|
|
|
|
import "context"
|
|
|
|
type acquisitionControlKey struct{}
|
|
|
|
// WithAcquisitionControl composes platform stopping with the existing quota policy.
|
|
func WithAcquisitionControl(ctx context.Context, before func(context.Context) error) context.Context {
|
|
return context.WithValue(ctx, acquisitionControlKey{}, before)
|
|
}
|
|
func CheckAcquisitionControl(ctx context.Context) error {
|
|
if before, ok := ctx.Value(acquisitionControlKey{}).(func(context.Context) error); ok {
|
|
return before(ctx)
|
|
}
|
|
return ctx.Err()
|
|
}
|