| 
									
										
										
										
											2021-07-15 20:30:06 +08:00
										 |  |  | package setting | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-28 21:10:05 +08:00
										 |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"gopkg.in/ini.v1" | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2021-07-15 20:30:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-13 21:27:51 +08:00
										 |  |  | const defaultDataProxyRowLimit = int64(1000000) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-15 20:30:06 +08:00
										 |  |  | func readDataProxySettings(iniFile *ini.File, cfg *Cfg) error { | 
					
						
							|  |  |  | 	dataproxy := iniFile.Section("dataproxy") | 
					
						
							|  |  |  | 	cfg.SendUserHeader = dataproxy.Key("send_user_header").MustBool(false) | 
					
						
							|  |  |  | 	cfg.DataProxyLogging = dataproxy.Key("logging").MustBool(false) | 
					
						
							|  |  |  | 	cfg.DataProxyTimeout = dataproxy.Key("timeout").MustInt(10) | 
					
						
							|  |  |  | 	cfg.DataProxyDialTimeout = dataproxy.Key("dialTimeout").MustInt(30) | 
					
						
							|  |  |  | 	cfg.DataProxyKeepAlive = dataproxy.Key("keep_alive_seconds").MustInt(30) | 
					
						
							|  |  |  | 	cfg.DataProxyTLSHandshakeTimeout = dataproxy.Key("tls_handshake_timeout_seconds").MustInt(10) | 
					
						
							|  |  |  | 	cfg.DataProxyExpectContinueTimeout = dataproxy.Key("expect_continue_timeout_seconds").MustInt(1) | 
					
						
							|  |  |  | 	cfg.DataProxyMaxConnsPerHost = dataproxy.Key("max_conns_per_host").MustInt(0) | 
					
						
							|  |  |  | 	cfg.DataProxyMaxIdleConns = dataproxy.Key("max_idle_connections").MustInt() | 
					
						
							|  |  |  | 	cfg.DataProxyIdleConnTimeout = dataproxy.Key("idle_conn_timeout_seconds").MustInt(90) | 
					
						
							| 
									
										
										
										
											2021-09-10 21:51:06 +08:00
										 |  |  | 	cfg.ResponseLimit = dataproxy.Key("response_limit").MustInt64(0) | 
					
						
							| 
									
										
										
										
											2021-09-13 21:27:51 +08:00
										 |  |  | 	cfg.DataProxyRowLimit = dataproxy.Key("row_limit").MustInt64(defaultDataProxyRowLimit) | 
					
						
							| 
									
										
										
										
											2023-02-28 21:10:05 +08:00
										 |  |  | 	cfg.DataProxyUserAgent = dataproxy.Key("user_agent").String() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if cfg.DataProxyUserAgent == "" { | 
					
						
							|  |  |  | 		cfg.DataProxyUserAgent = fmt.Sprintf("Grafana/%s", BuildVersion) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-09-13 21:27:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if cfg.DataProxyRowLimit <= 0 { | 
					
						
							|  |  |  | 		cfg.DataProxyRowLimit = defaultDataProxyRowLimit | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-07-15 20:30:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } |