2015-09-11 01:47:33 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package setting
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								type OrgQuota struct {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									User       int64 `target:"org_user"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									DataSource int64 `target:"data_source"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Dashboard  int64 `target:"dashboard"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ApiKey     int64 `target:"api_key"`
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-05 00:16:28 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									AlertRule  int64 `target:"alert_rule"`
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								type UserQuota struct {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Org int64 `target:"org_user"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								type GlobalQuota struct {
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-22 04:27:25 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Org          int64 `target:"org"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									User         int64 `target:"user"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									DataSource   int64 `target:"data_source"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Dashboard    int64 `target:"dashboard"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ApiKey       int64 `target:"api_key"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Session      int64 `target:"-"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									AlertRule    int64 `target:"alert_rule"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									File         int64 `target:"file"`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Correlations int64 `target:"correlations"`
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 01:47:33 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								type QuotaSettings struct {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Enabled bool
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Org     OrgQuota
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									User    UserQuota
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Global  GlobalQuota
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 01:47:33 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-30 22:21:04 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								func (cfg *Cfg) readQuotaSettings() {
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 01:47:33 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// set global defaults.
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-30 22:21:04 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									quota := cfg.Raw.Section("quota")
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cfg.Quota.Enabled = quota.Key("enabled").MustBool(false)
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// per ORG Limits
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cfg.Quota.Org = OrgQuota{
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										User:       quota.Key("org_user").MustInt64(10),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										DataSource: quota.Key("org_data_source").MustInt64(10),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Dashboard:  quota.Key("org_dashboard").MustInt64(10),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ApiKey:     quota.Key("org_api_key").MustInt64(10),
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-06 07:19:12 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										AlertRule:  quota.Key("org_alert_rule").MustInt64(100),
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// per User limits
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cfg.Quota.User = UserQuota{
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										Org: quota.Key("user_org").MustInt64(10),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Global Limits
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-15 03:08:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cfg.Quota.Global = GlobalQuota{
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-22 04:27:25 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										User:         quota.Key("global_user").MustInt64(-1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Org:          quota.Key("global_org").MustInt64(-1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										DataSource:   quota.Key("global_data_source").MustInt64(-1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Dashboard:    quota.Key("global_dashboard").MustInt64(-1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ApiKey:       quota.Key("global_api_key").MustInt64(-1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										Session:      quota.Key("global_session").MustInt64(-1),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										File:         quota.Key("global_file").MustInt64(-1),
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-06 07:19:12 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										AlertRule:    quota.Key("global_alert_rule").MustInt64(-1),
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-22 04:27:25 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										Correlations: quota.Key("global_correlations").MustInt64(-1),
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 23:17:10 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2015-09-11 01:47:33 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |