feat: Make maximum number of results and events configurable (#1110)
This commit is contained in:
@@ -4,6 +4,11 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultMaximumNumberOfResults = 100
|
||||
DefaultMaximumNumberOfEvents = 50
|
||||
)
|
||||
|
||||
var (
|
||||
ErrSQLStorageRequiresPath = errors.New("sql storage requires a non-empty path to be defined")
|
||||
ErrMemoryStorageDoesNotSupportPath = errors.New("memory storage does not support persistence, use sqlite if you want persistence on file")
|
||||
@@ -25,6 +30,12 @@ type Config struct {
|
||||
// as they happen, also known as the write-through caching strategy.
|
||||
// Does not apply if Config.Type is not TypePostgres or TypeSQLite.
|
||||
Caching bool `yaml:"caching,omitempty"`
|
||||
|
||||
// MaximumNumberOfResults is the number of results each endpoint should be able to provide
|
||||
MaximumNumberOfResults int `yaml:"maximum-number-of-results,omitempty"`
|
||||
|
||||
// MaximumNumberOfEvents is the number of events each endpoint should be able to provide
|
||||
MaximumNumberOfEvents int `yaml:"maximum-number-of-events,omitempty"`
|
||||
}
|
||||
|
||||
// ValidateAndSetDefaults validates the configuration and sets the default values (if applicable)
|
||||
@@ -38,5 +49,11 @@ func (c *Config) ValidateAndSetDefaults() error {
|
||||
if c.Type == TypeMemory && len(c.Path) > 0 {
|
||||
return ErrMemoryStorageDoesNotSupportPath
|
||||
}
|
||||
if c.MaximumNumberOfResults <= 0 {
|
||||
c.MaximumNumberOfResults = DefaultMaximumNumberOfResults
|
||||
}
|
||||
if c.MaximumNumberOfEvents <= 0 {
|
||||
c.MaximumNumberOfEvents = DefaultMaximumNumberOfEvents
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user