Skip to content

Expose Config structures outside package #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Changes from all 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
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