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)
| 63 | // The values come from the registry in the context, the global registry, |
| 64 | // or the default value. |
| 65 | func 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 | } |