Skip to content

Commit

Permalink
Expose Config structures outside package (envoyproxy#374)
Browse files Browse the repository at this point in the history
* 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 <arko@tetrate.io>
  • Loading branch information
arkodg authored and timcovar committed Jan 16, 2024
1 parent a5d46cf commit 9293683
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/config/config_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ type yamlReplaces struct {
Name string
}

type yamlRateLimit struct {
type YamlRateLimit struct {
RequestsPerUnit uint32 `yaml:"requests_per_unit"`
Unit string
Unlimited bool `yaml:"unlimited"`
Name string
Replaces []yamlReplaces
}

type yamlDescriptor struct {
type YamlDescriptor struct {
Key string
Value string
RateLimit *yamlRateLimit `yaml:"rate_limit"`
Descriptors []yamlDescriptor
RateLimit *YamlRateLimit `yaml:"rate_limit"`
Descriptors []YamlDescriptor
ShadowMode bool `yaml:"shadow_mode"`
}

type yamlRoot struct {
type YamlRoot struct {
Domain string
Descriptors []yamlDescriptor
Descriptors []YamlDescriptor
}

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

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

0 comments on commit 9293683

Please sign in to comment.