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