@@ -101,7 +101,8 @@ type ServerConfig struct {
101101 // Deprecated: use Keepalive.IdleTimeout instead.
102102 IdleTimeout time.Duration `mapstructure:"idle_timeout,omitempty"`
103103 // Deprecated: set Keepalive to None to disable keep-alives.
104- KeepAlivesEnabled * bool `mapstructure:"keep_alives_enabled,omitempty"`
104+ // Note: only the false value is meaningful; true is indistinguishable from the default.
105+ KeepAlivesEnabled bool `mapstructure:"keep_alives_enabled,omitempty"`
105106}
106107
107108type KeepaliveServerConfig struct {
@@ -128,11 +129,12 @@ func NewDefaultServerConfig() ServerConfig {
128129 Keepalive : configoptional .Default (KeepaliveServerConfig {
129130 IdleTimeout : 1 * time .Minute ,
130131 }),
132+ KeepAlivesEnabled : true ,
131133 }
132134}
133135
134136func (sc * ServerConfig ) Validate () error {
135- if sc .Keepalive .HasValue () && (sc .IdleTimeout != 0 || sc .KeepAlivesEnabled != nil ) {
137+ if sc .Keepalive .HasValue () && (sc .IdleTimeout != 0 || ! sc .KeepAlivesEnabled ) {
136138 return errors .New ("confighttp.ServerConfig: cannot use deprecated keepalive fields (idle_timeout, keep_alives_enabled) alongside the 'keepalive' section; migrate to the 'keepalive' section" )
137139 }
138140 return nil
@@ -205,7 +207,7 @@ func (sc *ServerConfig) ToServer(ctx context.Context, extensions map[component.I
205207 if sc .IdleTimeout != 0 {
206208 settings .Logger .Warn ("'idle_timeout' is deprecated; use 'keepalive.idle_timeout' instead" )
207209 }
208- if sc .KeepAlivesEnabled != nil {
210+ if ! sc .KeepAlivesEnabled {
209211 settings .Logger .Warn ("'keep_alives_enabled' is deprecated; set keepalive to null (keepalive: null) to disable keep-alives" )
210212 }
211213
@@ -326,7 +328,7 @@ func (sc *ServerConfig) ToServer(ctx context.Context, extensions map[component.I
326328
327329 // Convert deprecated fields into the canonical Keepalive optional so the
328330 // application logic below only has to deal with one struct.
329- if sc .KeepAlivesEnabled != nil && ! * sc .KeepAlivesEnabled {
331+ if ! sc .Keepalive . HasValue () && ! sc .KeepAlivesEnabled {
330332 sc .Keepalive = configoptional .None [KeepaliveServerConfig ]()
331333 } else if sc .IdleTimeout != 0 {
332334 sc .Keepalive = configoptional .Some (KeepaliveServerConfig {
0 commit comments