Skip to content

Commit 1fa4814

Browse files
arkodgbarroca
authored andcommitted
Expose Config structures outside package (envoyproxy#374)
* Allow downstream projects to reuse the config structure and generate the rate limit service config programatically w/o creating their own custom structures. Signed-off-by: Arko Dasgupta <[email protected]>
1 parent 507374e commit 1fa4814

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/config/config_impl.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ type yamlReplaces struct {
1717
Name string
1818
}
1919

20-
type yamlRateLimit struct {
20+
type YamlRateLimit struct {
2121
RequestsPerUnit uint32 `yaml:"requests_per_unit"`
2222
Unit string
2323
Unlimited bool `yaml:"unlimited"`
2424
Name string
2525
Replaces []yamlReplaces
2626
}
2727

28-
type yamlDescriptor struct {
28+
type YamlDescriptor struct {
2929
Key string
3030
Value string
31-
RateLimit *yamlRateLimit `yaml:"rate_limit"`
32-
Descriptors []yamlDescriptor
31+
RateLimit *YamlRateLimit `yaml:"rate_limit"`
32+
Descriptors []YamlDescriptor
3333
ShadowMode bool `yaml:"shadow_mode"`
3434
}
3535

36-
type yamlRoot struct {
36+
type YamlRoot struct {
3737
Domain string
38-
Descriptors []yamlDescriptor
38+
Descriptors []YamlDescriptor
3939
}
4040

4141
type rateLimitDescriptor struct {
@@ -116,7 +116,7 @@ func newRateLimitConfigError(config RateLimitConfigToLoad, err string) RateLimit
116116
// @param parentKey supplies the fully resolved key name that owns this config level.
117117
// @param descriptors supplies the YAML descriptors to load.
118118
// @param statsManager that owns the stats.Scope.
119-
func (this *rateLimitDescriptor) loadDescriptors(config RateLimitConfigToLoad, parentKey string, descriptors []yamlDescriptor, statsManager stats.Manager) {
119+
func (this *rateLimitDescriptor) loadDescriptors(config RateLimitConfigToLoad, parentKey string, descriptors []YamlDescriptor, statsManager stats.Manager) {
120120
for _, descriptorConfig := range descriptors {
121121
if descriptorConfig.Key == "" {
122122
panic(newRateLimitConfigError(config, "descriptor has empty key"))
@@ -245,7 +245,7 @@ func (this *rateLimitConfigImpl) loadConfig(config RateLimitConfigToLoad) {
245245
}
246246
validateYamlKeys(config, any)
247247

248-
var root yamlRoot
248+
var root YamlRoot
249249
err = yaml.Unmarshal([]byte(config.FileBytes), &root)
250250
if err != nil {
251251
errorText := fmt.Sprintf("error loading config file: %s", err.Error())

0 commit comments

Comments
 (0)