-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
config.go
44 lines (38 loc) · 1.45 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
package s3
import (
"fmt"
"time"
"github.com/elastic/beats/filebeat/harvester"
awscommon "github.com/elastic/beats/x-pack/libbeat/common/aws"
)
type config struct {
harvester.ForwarderConfig `config:",inline"`
QueueURL string `config:"queue_url" validate:"nonzero,required"`
VisibilityTimeout time.Duration `config:"visibility_timeout"`
AwsConfig awscommon.ConfigAWS `config:",inline"`
ExpandEventListFromField string `config:"expand_event_list_from_field"`
APITimeout time.Duration `config:"api_timeout"`
}
func defaultConfig() config {
return config{
ForwarderConfig: harvester.ForwarderConfig{
Type: "s3",
},
VisibilityTimeout: 300 * time.Second,
APITimeout: 120 * time.Second,
}
}
func (c *config) Validate() error {
if c.VisibilityTimeout < 0 || c.VisibilityTimeout.Hours() > 12 {
return fmt.Errorf("visibility timeout %v is not within the "+
"required range 0s to 12h", c.VisibilityTimeout)
}
if c.APITimeout < 0 || c.APITimeout > c.VisibilityTimeout/2 {
return fmt.Errorf("api timeout %v needs to be larger than"+
" 0s and smaller than half of the visibility timeout", c.APITimeout)
}
return nil
}