MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / AllFeatures

Function AllFeatures

pkg/experimental/feature.go:65–91  ·  view source on GitHub ↗

AllFeatures returns all features and their values. The values come from the registry in the context, the global registry, or the default value.

(ctx context.Context)

Source from the content-addressed store, hash-verified

63// The values come from the registry in the context, the global registry,
64// or the default value.
65func AllFeatures(ctx context.Context) map[string]bool {
66 definedFeaturesMu.RLock()
67 defer definedFeaturesMu.RUnlock()
68
69 features := make(map[string]bool, len(definedFeatures))
70 for k, v := range definedFeatures {
71 features[k] = v.defaultValue
72 }
73
74 globalFeatures := globalRegistry.allFeatures()
75 for k, v := range globalFeatures {
76 if _, isDefined := features[k]; isDefined {
77 features[k] = v
78 }
79 }
80
81 if r := registryFromContext(ctx); r != nil {
82 contextFeatures := r.allFeatures()
83 for k, v := range contextFeatures {
84 if _, isDefined := features[k]; isDefined {
85 features[k] = v
86 }
87 }
88 }
89
90 return features
91}

Callers 2

ServeHTTPMethod · 0.92
TestExperimentalFeaturesFunction · 0.85

Calls 2

registryFromContextFunction · 0.85
allFeaturesMethod · 0.80

Tested by 1

TestExperimentalFeaturesFunction · 0.68