-
Notifications
You must be signed in to change notification settings - Fork 225
/
config.go
34 lines (28 loc) · 977 Bytes
/
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
package gcp
import (
gpubsub "cloud.google.com/go/pubsub"
"github.com/kelseyhightower/envconfig"
)
// Config holds common credentials and config values for
// working with GCP PubSub.
type Config struct {
ProjectID string `envconfig:"GOOGLE_CLOUD_PROJECT"`
// For publishing
Topic string `envconfig:"GCP_PUBSUB_TOPIC"`
// Batch settings for GCP publisher
// See: https://godoc.org/cloud.google.com/go/pubsub#PublishSettings
// Notes:
// This config will not allow you to set zero values for PublishSettings.
// Applications using these settings should be aware that Publish requests
// will block until the lowest of the thresholds in PublishSettings is met.
PublishSettings gpubsub.PublishSettings
// For subscribing
Subscription string `envconfig:"GCP_PUBSUB_SUBSCRIPTION"`
}
// LoadConfigFromEnv will attempt to load a PubSub config
// from environment variables.
func LoadConfigFromEnv() Config {
var ps Config
envconfig.Process("", &ps)
return ps
}