88 "time"
99
1010 "go.opentelemetry.io/collector/component"
11+ "go.opentelemetry.io/collector/config/configoptional"
1112 "go.opentelemetry.io/collector/exporter/exporterhelper/internal/request"
1213)
1314
@@ -31,10 +32,9 @@ type Config struct {
3132 // If true, the component will wait for space; otherwise, operations will immediately return a retryable error.
3233 BlockOnOverflow bool `mapstructure:"block_on_overflow"`
3334
34- // StorageID if not empty, enables the persistent storage and uses the component specified
35+ // StorageID, if not empty, enables the persistent storage and uses the component specified
3536 // as a storage extension for the persistent queue.
36- // TODO: This will be changed to Optional when available.
37- StorageID * component.ID `mapstructure:"storage"`
37+ StorageID configoptional.Optional [component.ID ] `mapstructure:"storage"`
3838
3939 // NumConsumers is the maximum number of concurrent consumers from the queue.
4040 // This applies across all different optional configurations from above (e.g. wait_for_result, blockOnOverflow, persistent, etc.).
@@ -43,8 +43,7 @@ type Config struct {
4343 NumConsumers int `mapstructure:"num_consumers"`
4444
4545 // BatchConfig it configures how the requests are consumed from the queue and batch together during consumption.
46- // TODO: This will be changed to Optional when available.
47- Batch * BatchConfig `mapstructure:"batch"`
46+ Batch configoptional.Optional [BatchConfig ] `mapstructure:"batch"`
4847}
4948
5049// Validate checks if the Config is valid
@@ -62,18 +61,18 @@ func (cfg *Config) Validate() error {
6261 }
6362
6463 // Only support request sizer for persistent queue at this moment.
65- if cfg .StorageID != nil && cfg .WaitForResult {
64+ if cfg .StorageID . HasValue () && cfg .WaitForResult {
6665 return errors .New ("`wait_for_result` is not supported with a persistent queue configured with `storage`" )
6766 }
6867
69- if cfg .Batch != nil {
68+ if cfg .Batch . HasValue () {
7069 // Only support items or bytes sizer for batch at this moment.
7170 if cfg .Sizer != request .SizerTypeItems && cfg .Sizer != request .SizerTypeBytes {
7271 return errors .New ("`batch` supports only `items` or `bytes` sizer" )
7372 }
7473
7574 // Avoid situations where the queue is not able to hold any data.
76- if cfg .Batch .MinSize > cfg .QueueSize {
75+ if cfg .Batch .Get (). MinSize > cfg .QueueSize {
7776 return errors .New ("`min_size` must be less than or equal to `queue_size`" )
7877 }
7978 }
0 commit comments