forked from nytimes/gizmo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
54 lines (46 loc) · 1.58 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
45
46
47
48
49
50
51
52
53
54
package aws
import (
"time"
"github.com/NYTimes/gizmo/config"
"github.com/NYTimes/gizmo/config/aws"
)
type (
// SQSConfig holds the info required to work with Amazon SQS
SQSConfig struct {
aws.Config
QueueName string `envconfig:"AWS_SQS_NAME"`
// MaxMessages will override the DefaultSQSMaxMessages.
MaxMessages *int64 `envconfig:"AWS_SQS_MAX_MESSAGES"`
// TimeoutSeconds will override the DefaultSQSTimeoutSeconds.
TimeoutSeconds *int64 `envconfig:"AWS_SQS_TIMEOUT_SECONDS"`
// SleepInterval will override the DefaultSQSSleepInterval.
SleepInterval *time.Duration `envconfig:"AWS_SQS_SLEEP_INTERVAL"`
// DeleteBufferSize will override the DefaultSQSDeleteBufferSize.
DeleteBufferSize *int `envconfig:"AWS_SQS_DELETE_BUFFER_SIZE"`
// ConsumeBase64 is a flag to signal the subscriber to base64 decode the payload
// before returning it. If it is not set in the config, the flag will default
// to 'true'.
ConsumeBase64 *bool `envconfig:"AWS_SQS_CONSUME_BASE64"`
}
// SNSConfig holds the info required to work with Amazon SNS.
SNSConfig struct {
aws.Config
Topic string `envconfig:"AWS_SNS_TOPIC"`
}
)
// LoadSQSConfigFromEnv will attempt to load the SQSConfig struct
// from environment variables. If not populated, nil
// is returned.
func LoadSQSConfigFromEnv() SQSConfig {
var cfg SQSConfig
config.LoadEnvConfig(&cfg)
return cfg
}
// LoadSNSConfigFromEnv will attempt to load the SNSConfig struct
// from environment variables. If not populated, nil
// is returned.
func LoadSNSConfigFromEnv() SNSConfig {
var cfg SNSConfig
config.LoadEnvConfig(&cfg)
return cfg
}