github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/common/config.go (about) 1 // Copyright (c) 2017-2018 Uber Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package common 16 17 import ( 18 "net/http" 19 ) 20 21 // TimezoneConfig is the static config for timezone column support 22 type TimezoneConfig struct { 23 // table to lookup timezone columns 24 TableName string `yaml:"table_name"` 25 } 26 27 // QueryConfig is the static configuration for query. 28 type QueryConfig struct { 29 // how much portion of the device memory we are allowed use 30 DeviceMemoryUtilization float32 `yaml:"device_memory_utilization"` 31 // timeout in seconds for choosing device 32 DeviceChoosingTimeout int `yaml:"device_choosing_timeout"` 33 TimezoneTable TimezoneConfig `yaml:"timezone_table"` 34 } 35 36 // DiskStoreConfig is the static configuration for disk store. 37 type DiskStoreConfig struct { 38 WriteSync bool `yaml:"write_sync"` 39 } 40 41 // HTTPConfig is the static configuration for main http server (query and schema). 42 type HTTPConfig struct { 43 MaxConnections int `yaml:"max_connections"` 44 ReadTimeOutInSeconds int `yaml:"read_time_out_in_seconds"` 45 WriteTimeOutInSeconds int `yaml:"write_time_out_in_seconds"` 46 } 47 48 // ControllerConfig is the config for ares-controller client 49 type ControllerConfig struct { 50 Address string `yaml:"address"` 51 Headers http.Header `yaml:"headers"` 52 TimeoutSec int `yaml:"timeout"` 53 } 54 55 // GatewayConfig is the config for all gateway 56 type GatewayConfig struct { 57 Controller *ControllerConfig `yaml:"controller,omitempty"` 58 } 59 60 // ClusterConfig is the config for starting current instance with cluster mode 61 type ClusterConfig struct { 62 // Enable controls whether to start in cluster mode 63 Enable bool `yaml:"enable"` 64 // ClusterName is the cluster to join 65 ClusterName string `yaml:"cluster_name"` 66 // InstanceName is the cluster wide unique name to identify current instance 67 // it can be static configured in yaml, or dynamically set on start up 68 InstanceName string `yaml:"instance_name"` 69 } 70 71 // AresServerConfig is config specific for ares server. 72 type AresServerConfig struct { 73 // HTTP port for serving. 74 Port int `yaml:"port"` 75 76 // HTTP port for debugging. 77 DebugPort int `yaml:"debug_port"` 78 79 // Directory path that stores the data and schema on local disk. 80 RootPath string `yaml:"root_path"` 81 82 // Total memory size ares can use. 83 TotalMemorySize int64 `yaml:"total_memory_size"` 84 85 // Whether to turn off scheduler. 86 SchedulerOff bool `yaml:"scheduler_off"` 87 88 // Build version of the server currently running 89 Version string `yaml:"version"` 90 91 // environment 92 Env string `yaml:"env"` 93 94 Query QueryConfig `yaml:"query"` 95 DiskStore DiskStoreConfig `yaml:"disk_store"` 96 HTTP HTTPConfig `yaml:"http"` 97 Cluster ClusterConfig `yaml:"cluster"` 98 Gateway GatewayConfig `yaml:"gateway"` 99 }