From d3420bcd1923bb36f79a4d91da8fa2661a57f4d7 Mon Sep 17 00:00:00 2001 From: Yunchi Luo Date: Wed, 17 Jul 2019 11:40:44 -0400 Subject: [PATCH] split out config structs So that `Relay` can be configured programmatically. --- relay.go | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/relay.go b/relay.go index 9b8b5431..c98125b2 100644 --- a/relay.go +++ b/relay.go @@ -131,34 +131,42 @@ func (c CommonMetricsConfig) enabled() bool { // Config describes the configuration for a relay instance type Config struct { - Main struct { - ExitOnError bool - IgnoreConnectionErrors bool - StreamUri string - BaseUri string - Port int - HeartbeatIntervalSecs int - } - Events events.Config - Redis struct { - Host string - Port int - Url string - LocalTtl int - } - Consul struct { - Host string - LocalTtl int - } - DynamoDB struct { - Enabled bool - TableName string - LocalTtl int - } + Main MainConfig + Events events.Config + Redis RedisConfig + Consul ConsulConfig + DynamoDB DynamoDBConfig Environment map[string]*EnvConfig MetricsConfig } +type MainConfig struct { + ExitOnError bool + IgnoreConnectionErrors bool + StreamUri string + BaseUri string + Port int + HeartbeatIntervalSecs int +} + +type ConsulConfig struct { + Host string + LocalTtl int +} + +type RedisConfig struct { + Host string + Port int + Url string + LocalTtl int +} + +type DynamoDBConfig struct { + Enabled bool + TableName string + LocalTtl int +} + type MetricsConfig struct { Datadog DatadogConfig Stackdriver StackdriverConfig