forked from nyaruka/courier
-
Notifications
You must be signed in to change notification settings - Fork 2
/
courier.go
87 lines (61 loc) · 3.29 KB
/
courier.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package config
import (
"github.com/koding/multiconfig"
)
// Courier is our top level configuration object
type Courier struct {
// Backend is the backend that will be used by courier (currently only rapidpro is supported)
Backend string `default:"rapidpro"`
// SentryDSN is the DSN used for logging errors to Sentry
SentryDSN string `default:""`
// Domain is the domain courier is exposed on
Domain string `default:"localhost"`
// Port is the port courier will listen on
Port int `default:"8080"`
// DB is a URL describing how to connect to our database
DB string `default:"postgres://courier@localhost/courier?sslmode=disable"`
// Redis is a URL describing how to connect to Redis
Redis string `default:"redis://localhost:6379/0"`
// SpoolDir is the local directory where courier will write statuses or msgs that need to be retried (needs to be writable)
SpoolDir string `default:"/var/spool/courier"`
// S3Region is the S3 region we will write attachments to
S3Region string `default:"us-east-1"`
// S3MediaBucket is the S3 bucket we will write attachments to
S3MediaBucket string `default:"courier-media"`
// S3MediaPrefix is the prefix that will be added to attachment filenames
S3MediaPrefix string `default:"/media/"`
// AWSAccessKeyID is the access key id to use when authenticating S3
AWSAccessKeyID string `default:"missing_aws_access_key_id"`
// AWSAccessKeyID is the secret access key id to use when authenticating S3
AWSSecretAccessKey string `default:"missing_aws_secret_access_key"`
// MaxWorkers it the maximum number of go routines that will be used for sending (set to 0 to disable sending)
MaxWorkers int `default:"32"`
// LibratoUsername is the username that will be used to authenticate to Librato
LibratoUsername string `default:""`
// LibratoToken is the token that will be used to authenticate to Librato
LibratoToken string `default:""`
// StatusUsername is the username that is needed to authenticate against the /status endpoint
StatusUsername string `default:""`
// StatusPassword is the password that is needed to authenticate against the /status endpoint
StatusPassword string `default:""`
// LogLevel controls the logging level courier uses
LogLevel string `default:"error"`
// IgnoreDeliveryReports controls whether we ignore delivered status reports (errors will still be handled)
IgnoreDeliveryReports bool `default:"false"`
// IncludeChannels is the list of channels to enable, empty means include all
IncludeChannels []string
// ExcludeChannels is the list of channels to exclude, empty means exclude none
ExcludeChannels []string
// Version is the version that will be sent in headers
Version string `default:"Dev"`
}
// NewWithPath returns a new instance of Loader to read from the given configuration file using our config options
func NewWithPath(path string) *multiconfig.DefaultLoader {
loaders := []multiconfig.Loader{}
loaders = append(loaders, &multiconfig.TagLoader{})
loaders = append(loaders, &multiconfig.TOMLLoader{Path: path})
loaders = append(loaders, &multiconfig.EnvironmentLoader{CamelCase: true})
loaders = append(loaders, &multiconfig.FlagLoader{CamelCase: true})
loader := multiconfig.MultiLoader(loaders...)
return &multiconfig.DefaultLoader{Loader: loader, Validator: multiconfig.MultiValidator(&multiconfig.RequiredValidator{})}
}