mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-10-31 00:55:06 +01:00 
			
		
		
		
	Add config option for HTTP keep-alives
This commit is contained in:
		| @@ -28,6 +28,9 @@ type HttpReceiverConfig struct { | ||||
| 	IdleTimeout string `json:"idle_timeout"` | ||||
| 	idleTimeout time.Duration | ||||
|  | ||||
| 	// Controls whether HTTP keep-alives are enabled. By default, keep-alives are enabled | ||||
| 	KeepAlivesEnabled bool `json:"keep_alives_enabled"` | ||||
|  | ||||
| 	// Basic authentication | ||||
| 	Username     string `json:"username"` | ||||
| 	Password     string `json:"password"` | ||||
| @@ -47,6 +50,7 @@ func (r *HttpReceiver) Init(name string, config json.RawMessage) error { | ||||
|  | ||||
| 	// Set default values | ||||
| 	r.config.Port = HTTP_RECEIVER_PORT | ||||
| 	r.config.KeepAlivesEnabled = true | ||||
| 	// should be larger than the measurement interval to keep the connection open | ||||
| 	r.config.IdleTimeout = "120s" | ||||
|  | ||||
| @@ -100,6 +104,7 @@ func (r *HttpReceiver) Init(name string, config json.RawMessage) error { | ||||
| 		Handler:     nil, // handler to invoke, http.DefaultServeMux if nil | ||||
| 		IdleTimeout: r.config.idleTimeout, | ||||
| 	} | ||||
| 	r.server.SetKeepAlivesEnabled(r.config.KeepAlivesEnabled) | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
| @@ -23,6 +23,7 @@ The `http` receiver can be used receive metrics through HTTP POST requests. | ||||
| - `port`: Listen port | ||||
| - `path`: URL path for the write endpoint | ||||
| - `idle_timeout`: Maximum amount of time to wait for the next request when keep-alives are enabled should be larger than the measurement interval to keep the connection open | ||||
| - `keep_alives_enabled`: Controls whether HTTP keep-alives are enabled. By default, keep-alives are enabled. | ||||
| - `username`: username for basic authentication | ||||
| - `password`: password for basic authentication | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user