Skip to content

Commit

Permalink
move proxy names to client level
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Sep 22, 2024
1 parent 2aa0c85 commit 04ba621
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 0 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ type Config struct {
UnifiedProxy configtypes.UnifiedProxy `mapstructure:"unified_proxy" json:"unified_proxy" envconfig:"unified_proxy"`
// Proxies is a configuration for granular events proxies. See also UnifiedProxy.
Proxies configtypes.Proxies `mapstructure:"proxies" json:"proxies" envconfig:"proxies"`
// ConnectProxyName is a name of proxy to use for connect events. When not set connect events are not proxied.
ConnectProxyName string `mapstructure:"connect_proxy_name" json:"connect_proxy_name" envconfig:"connect_proxy_name"`
// RefreshProxyName is a name of proxy to use for refresh events. When not set refresh events are not proxied.
RefreshProxyName string `mapstructure:"refresh_proxy_name" json:"refresh_proxy_name" envconfig:"refresh_proxy_name"`

// OpenTelemetry is a configuration for OpenTelemetry tracing.
OpenTelemetry configtypes.OpenTelemetry `mapstructure:"opentelemetry" json:"opentelemetry" envconfig:"opentelemetry"`
Expand Down
16 changes: 8 additions & 8 deletions internal/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ func (c Config) Validate() error {

proxyNames = append(proxyNames, UnifiedProxyName) // channel options can use global proxy name.

if c.ConnectProxyName != "" && !slices.Contains(proxyNames, c.ConnectProxyName) {
return fmt.Errorf("proxy %s not found for connect", c.ConnectProxyName)
if c.Client.ConnectProxyName != "" && !slices.Contains(proxyNames, c.Client.ConnectProxyName) {
return fmt.Errorf("proxy %s not found for connect", c.Client.ConnectProxyName)
}
if c.RefreshProxyName != "" && !slices.Contains(proxyNames, c.RefreshProxyName) {
return fmt.Errorf("proxy %s not found for refresh", c.RefreshProxyName)
if c.Client.RefreshProxyName != "" && !slices.Contains(proxyNames, c.Client.RefreshProxyName) {
return fmt.Errorf("proxy %s not found for refresh", c.Client.RefreshProxyName)
}
if c.ConnectProxyName == UnifiedProxyName && c.UnifiedProxy.ConnectEndpoint == "" {
return fmt.Errorf("no connect_endpoint set for unified_proxy, can't use `%s` proxy name for connect proxy", UnifiedProxyName)
if c.Client.ConnectProxyName == UnifiedProxyName && c.UnifiedProxy.ConnectEndpoint == "" {
return fmt.Errorf("no connect_endpoint set for unified_proxy, can't use `%s` proxy name for client connect proxy", UnifiedProxyName)
}
if c.RefreshProxyName == UnifiedProxyName && c.UnifiedProxy.RefreshEndpoint == "" {
return fmt.Errorf("no refresh_endpoint set for unified_proxy, can't use `%s` proxy name for refresh proxy", UnifiedProxyName)
if c.Client.RefreshProxyName == UnifiedProxyName && c.UnifiedProxy.RefreshEndpoint == "" {
return fmt.Errorf("no refresh_endpoint set for unified_proxy, can't use `%s` proxy name for client refresh proxy", UnifiedProxyName)
}
if err := validateSecondPrecisionDuration(c.Channel.HistoryMetaTTL); err != nil {
return fmt.Errorf("in channel.history_meta_ttl: %v", err)
Expand Down
5 changes: 5 additions & 0 deletions internal/configtypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ type Shutdown struct {
}

type Client struct {
// ConnectProxyName is a name of proxy to use for connect events. When not set connect events are not proxied.
ConnectProxyName string `mapstructure:"connect_proxy_name" json:"connect_proxy_name" envconfig:"connect_proxy_name"`
// RefreshProxyName is a name of proxy to use for refresh events. When not set refresh events are not proxied.
RefreshProxyName string `mapstructure:"refresh_proxy_name" json:"refresh_proxy_name" envconfig:"refresh_proxy_name"`

// AllowedOrigins is a list of allowed origins for client connections.
AllowedOrigins []string `mapstructure:"allowed_origins" json:"allowed_origins" envconfig:"allowed_origins"`

Expand Down
4 changes: 2 additions & 2 deletions internal/runutil/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func buildProxyMap(cfg config.Config) (*client.ProxyMap, bool) {

var keepHeadersInContext bool

connectProxyName := cfg.ConnectProxyName
connectProxyName := cfg.Client.ConnectProxyName
if connectProxyName != "" {
var p proxy.Config
if connectProxyName == config.UnifiedProxyName {
Expand All @@ -58,7 +58,7 @@ func buildProxyMap(cfg config.Config) (*client.ProxyMap, bool) {
keepHeadersInContext = true
}

refreshProxyName := cfg.RefreshProxyName
refreshProxyName := cfg.Client.RefreshProxyName
if refreshProxyName != "" {
var p proxy.Config
if refreshProxyName == config.UnifiedProxyName {
Expand Down

0 comments on commit 04ba621

Please sign in to comment.