Added extra description
@@ -8,32 +8,22 @@ import (
// Specification for basic configurations
type Specification struct {
- Port int `envconfig:"PORT" default:"8080"`
- APIPort int `envconfig:"API_PORT" default:"8081"`
+ Port int `envconfig:"PORT" default:"8080" description:"Default application port"`
+ APIPort int `envconfig:"API_PORT" default:"8081" description:"Admin API port"`
Debug bool `envconfig:"DEBUG" description:"Enable debug mode"`
LogLevel string `envconfig:"LOG_LEVEL" default:"info" description:"Log level"`
GraceTimeOut int64 `envconfig:"GRACE_TIMEOUT" description:"Duration to give active requests a chance to finish during hot-reload"`
MaxIdleConnsPerHost int `envconfig:"MAX_IDLE_CONNS_PER_HOST" description:"If non-zero, controls the maximum idle (keep-alive) to keep per-host."`
InsecureSkipVerify bool `envconfig:"INSECURE_SKIP_VERIFY" description:"Disable SSL certificate verification"`
- // The Storage DSN, this could be `memory` or `redis`
- StorageDSN string `envconfig:"STORAGE_DSN" default:"memory://localhost"`
-
- // Path of certificate when using TLS
- CertPathTLS string `envconfig:"CERT_PATH"`
-
- // Path of key when using TLS
- KeyPathTLS string `envconfig:"KEY_PATH"`
-
- // Flush interval for upgraded Proxy connections
- BackendFlushInterval time.Duration `envconfig:"BACKEND_FLUSH_INTERVAL" default:"20ms"`
-
- // Defines the time period of how often the idle connections maintained
- // by the proxy are closed.
- CloseIdleConnsPeriod time.Duration `envconfig:"CLOSE_IDLE_CONNS_PERIOD"`
-
+ StorageDSN string `envconfig:"STORAGE_DSN" default:"memory://localhost" description:"The Storage DSN, this could be 'memory' or 'redis'"`
+ CertPathTLS string `envconfig:"CERT_PATH" description:"Path of certificate when using TLS"`
+ KeyPathTLS string `envconfig:"KEY_PATH" description:"Path of key when using TLS"`
+ BackendFlushInterval time.Duration `envconfig:"BACKEND_FLUSH_INTERVAL" default:"20ms" description:"Flush interval for upgraded Proxy connections"`
+ CloseIdleConnsPeriod time.Duration `envconfig:"CLOSE_IDLE_CONNS_PERIOD" description:"Defines the time period of how often the idle connections maintained by the proxy are closed."`
Database Database
Statsd Statsd
Credentials Credentials
+ Tracing Tracing
}
// IsHTTPS checks if you have https enabled
@@ -70,6 +60,36 @@ type Credentials struct {
Password string `envconfig:"ADMIN_PASSWORD" default:"admin"`
}
+// GoogleCloudTracing holds the Google Application Default Credentials
+type GoogleCloudTracing struct {
+ ProjectID string `envconfig:"TRACING_GC_PROJECT_ID"`
+ Email string `envconfig:"TRACING_GC_EMAIL"`
+ PrivateKey string `envconfig:"TRACING_GC_PRIVATE_KEY"`
+ PrivateKeyID string `envconfig:"TRACING_GC_PRIVATE_ID"`
+}
+
+// AppdashTracing holds the Appdash tracing configuration
+type AppdashTracing struct {
+ DSN string `envconfig:"TRACING_APPDASH_DSN"`
+ URL string `envconfig:"TRACING_APPDASH_URL" default:"http://localhost:8700"`
+}
+
+// Tracing represents the distributed tracing configuration
+type Tracing struct {
+ GoogleCloudTracing GoogleCloudTracing
+ AppdashTracing AppdashTracing
+}
+
+// IsGoogleCloudEnabled checks if google cloud is enabled
+func (t Tracing) IsGoogleCloudEnabled() bool {
+ return len(t.GoogleCloudTracing.Email) > 0 && len(t.GoogleCloudTracing.PrivateKey) > 0 && len(t.GoogleCloudTracing.PrivateKeyID) > 0
+}
+
+// IsAppdashEnabled checks if appdash is enabled
+func (t Tracing) IsAppdashEnabled() bool {
+ return len(t.AppdashTracing.DSN) > 0
+}
+
//LoadEnv loads environment variables
func LoadEnv() (*Specification, error) {
var config Specification
