Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
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
5 changes: 5 additions & 0 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ is currently processing a task.
)

// keys for frontend
FrontendAllowedExperiments = NewNamespaceTypedSetting(
"frontend.allowedExperiments",
[]string(nil),
`FrontendAllowedExperiments is a list of experiment names that can be enabled via the temporal-experimental header for a specific namespace.`,
)
FrontendHTTPAllowedHosts = NewGlobalTypedSettingWithConverter(
"frontend.httpAllowedHosts",
ConvertWildcardStringListToRegexp,
Expand Down
26 changes: 26 additions & 0 deletions common/headers/headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package headers

import (
"context"
"strings"

"google.golang.org/grpc/metadata"
)
Expand All @@ -18,6 +19,8 @@ const (
CallerNameHeaderName = "caller-name"
CallerTypeHeaderName = "caller-type"
CallOriginHeaderName = "call-initiation"

ExperimentalHeaderName = "temporal-experimental"
)

var (
Expand Down Expand Up @@ -90,3 +93,26 @@ func (h GRPCHeaderGetter) Get(key string) string {
}
return ""
}

// IsExperimentEnabled checks if a specific experiment is present in the x-temporal-experimental header.
// Returns true if the experiment is explicitly listed or if "*" (wildcard) is present.
func IsExperimentEnabled(ctx context.Context, experiment string) bool {
experimentalValues := metadata.ValueFromIncomingContext(ctx, ExperimentalHeaderName)

for _, headerValue := range experimentalValues {
if headerValue == "" {
continue
}
// Split by comma in case multiple experiments are sent
requestedExperiments := strings.Split(headerValue, ",")
for _, requested := range requestedExperiments {
requested = strings.TrimSpace(requested)
// Check for wildcard or exact match
if requested == "*" || strings.EqualFold(requested, experiment) {
return true
}
}
}

return false
}
Loading
Loading