Skip to content

Commit

Permalink
Add Validate method to QueueSettings struct
Browse files Browse the repository at this point in the history
  • Loading branch information
FreakyNobleGas committed Feb 3, 2022
1 parent 32301d9 commit 1bf5ff4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions exporter/exporterhelper/queued_retry_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ func DefaultQueueSettings() QueueSettings {
}
}

// Validate checks if the QueueSettings configuration is valid
func (qCfg *QueueSettings) Validate() error {
if qCfg.QueueSize < 0 {
return fmt.Errorf("queue size can't be negative")
}

if qCfg.Enabled && qCfg.QueueSize == 0 {
return fmt.Errorf("a 0 size queue will drop all the data")
}

return nil
}

var (
errNoStorageClient = errors.New("no storage client extension found")
errMultipleStorageClients = errors.New("multiple storage extensions found")
Expand Down
13 changes: 13 additions & 0 deletions exporter/exporterhelper/queued_retry_inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ func DefaultQueueSettings() QueueSettings {
}
}

// Validate checks if the QueueSettings configuration is valid
func (qCfg *QueueSettings) Validate() error {
if qCfg.QueueSize < 0 {
return fmt.Errorf("queue size can't be negative")
}

if qCfg.Enabled && qCfg.QueueSize == 0 {
return fmt.Errorf("a 0 size queue will drop all the data")
}

return nil
}

type queuedRetrySender struct {
fullName string
cfg QueueSettings
Expand Down

0 comments on commit 1bf5ff4

Please sign in to comment.