1 module settings; 2 3 import hunt.util.Configuration; 4 5 @Configuration("http") 6 struct TestHttpConfig 7 { 8 @Value("listen") 9 int value; 10 11 string addr; 12 } 13 14 @Configuration("server") 15 struct ServerSettings 16 { 17 @Value("listen") 18 string ip = "127.0.0.1"; 19 20 ushort port = 8080; 21 } 22 23 24 @Configuration("package") 25 class PackageSettings 26 { 27 string name; 28 } 29 30 @Configuration("app") 31 class TestConfig 32 { 33 string name = "Hunt"; 34 35 @Value("time") 36 double time; 37 38 PackageSettings package1; 39 40 @Value("pkg") 41 PackageSettings package2; 42 43 ServerSettings server1; 44 45 @Value("httpserver") 46 ServerSettings server2; 47 48 @Value("interval", true) 49 int interval1 = 500; 50 51 @Value("interval", true) 52 int interval2 = 600; 53 54 int interval3 = 700; 55 56 @property void description(string d) 57 { 58 _desc = d; 59 } 60 61 @property string description() 62 { 63 return _desc; 64 } 65 66 private string _desc = "Putao Ltd."; 67 68 } 69 70 71 class BuilderTest1Config 72 { 73 string name = "Hunt"; 74 75 @Value("time") 76 double time; 77 78 ServerSettings server1; 79 80 @Value("httpserver") 81 ServerSettings server2; 82 83 @Value("interval", true) 84 int interval1 = 500; 85 86 @Value("interval", true) 87 int interval2 = 600; 88 89 int interval3 = 700; 90 91 } 92 93 94 class ArrayTestConfig { 95 string name; 96 int[] ages; 97 string[] users; 98 ServerSettings[] servers; 99 } 100 101 class TestConfigEx : TestConfig 102 { 103 string fullName = "Putao"; 104 } 105 106 107 @Configuration("hunt") 108 class AppConfig 109 { 110 struct ApplicationConf 111 { 112 string name = "HUNT APPLICATION"; 113 string baseUrl; 114 string defaultCookieDomain = ".example.com"; 115 string defaultLanguage = "zh-CN"; 116 string languages = "zh-CN,en-US"; 117 string secret = "CD6CABB1123C86EDAD9"; 118 string encoding = "utf-8"; 119 int staticFileCacheMinutes = 30; 120 } 121 122 struct SessionConf 123 { 124 string storage = "memory"; 125 string prefix = "huntsession_"; 126 string args = "/tmp"; 127 uint expire = 3600; 128 } 129 130 struct CacheConf 131 { 132 string storage = "memory"; 133 string args = "/tmp"; 134 bool enableL2 = false; 135 } 136 137 struct HttpConf 138 { 139 string address = "0.0.0.0"; 140 ushort port = 8080; 141 uint workerThreads = 4; 142 uint ioThreads = 2; 143 size_t keepAliveTimeOut = 30; 144 size_t maxHeaderSize = 60 * 1024; 145 int cacheControl; 146 string path; 147 } 148 149 struct HttpsConf 150 { 151 bool enabled = false; 152 string protocol; 153 string keyStore; 154 string keyStoreType; 155 string keyStorePassword; 156 } 157 158 struct RouteConf 159 { 160 string groups; 161 } 162 163 struct LogConfig 164 { 165 string level = "all"; 166 string path; 167 string file = ""; 168 bool disableConsole = false; 169 string maxSize = "8M"; 170 uint maxNum = 8; 171 } 172 173 struct MemcacheConf 174 { 175 bool enabled = false; 176 string servers; 177 } 178 179 struct RedisConf 180 { 181 bool enabled = false; 182 string host = "127.0.0.1"; 183 string password = ""; 184 ushort database = 0; 185 ushort port = 6379; 186 uint timeout = 0; 187 } 188 189 struct UploadConf 190 { 191 string path; 192 uint maxSize = 4 * 1024 * 1024; 193 } 194 195 struct DownloadConfig 196 { 197 string path = "downloads"; 198 } 199 200 struct MailSmtpConf 201 { 202 string host; 203 string channel; 204 ushort port; 205 string protocol; 206 string user; 207 string password; 208 } 209 210 struct MailConf 211 { 212 MailSmtpConf smtp; 213 } 214 215 struct DbPoolConf 216 { 217 uint maxConnection = 10; 218 uint minConnection = 10; 219 uint timeout = 10000; 220 } 221 222 struct DBConfig 223 { 224 string url; 225 DbPoolConf pool; 226 } 227 228 struct DateConf 229 { 230 string format; 231 string timeZone; 232 } 233 234 struct CornConf 235 { 236 string noon; 237 } 238 239 struct ServiceConf 240 { 241 string address = "127.0.0.1"; 242 ushort port; 243 int workerThreads; 244 string password; 245 } 246 247 struct RpcConf 248 { 249 bool enabled = true; 250 ServiceConf service; 251 } 252 253 struct Views 254 { 255 string path = "views/"; 256 string ext = ".dhtml"; 257 } 258 259 DBConfig database; 260 ApplicationConf application; 261 SessionConf session; 262 CacheConf cache; 263 HttpConf http; 264 HttpsConf https; 265 RouteConf route; 266 MemcacheConf memcache; 267 RedisConf redis; 268 LogConfig log; 269 UploadConf upload; 270 DownloadConfig download; 271 CornConf cron; 272 DateConf date; 273 MailConf mail; 274 RpcConf rpc; 275 Views view; 276 }