1 module settings;
2 
3 import kiss.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 = "Kiss";
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 = "Kiss";
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 TestConfigEx : TestConfig
95 {
96     string fullName = "Putao";
97 }
98 
99 
100 @Configuration("hunt")
101 class AppConfig
102 {
103     struct ApplicationConf
104     {
105         string name = "HUNT APPLICATION";
106         string baseUrl;
107         string defaultCookieDomain = ".example.com";
108         string defaultLanguage = "zh-CN";
109         string languages = "zh-CN,en-US";
110         string secret = "CD6CABB1123C86EDAD9";
111         string encoding = "utf-8";
112         int staticFileCacheMinutes = 30;
113     }
114 
115     struct SessionConf
116     {
117         string storage = "memory";
118         string prefix = "huntsession_";
119         string args = "/tmp";
120         uint expire = 3600;
121     }
122 
123     struct CacheConf
124     {
125         string storage = "memory";
126         string args = "/tmp";
127         bool enableL2 = false;
128     }
129 
130     struct HttpConf
131     {
132         string address = "0.0.0.0";
133         ushort port = 8080;
134         uint workerThreads = 4;
135         uint ioThreads = 2;
136         size_t keepAliveTimeOut = 30;
137         size_t maxHeaderSize = 60 * 1024;
138         int cacheControl;
139         string path;
140     }
141 
142     struct HttpsConf
143     {
144         bool enabled = false;
145         string protocol;
146         string keyStore;
147         string keyStoreType;
148         string keyStorePassword;
149     }
150 
151     struct RouteConf
152     {
153         string groups;
154     }
155 
156     struct LogConfig
157     {
158         string level = "all";
159         string path;
160         string file = "";
161         bool disableConsole = false;
162         string maxSize = "8M";
163         uint maxNum = 8;
164     }
165 
166     struct MemcacheConf
167     {
168         bool enabled = false;
169         string servers;
170     }
171 
172     struct RedisConf
173     {
174         bool enabled = false;
175         string host = "127.0.0.1";
176         string password = "";
177         ushort database = 0;
178         ushort port = 6379;
179         uint timeout = 0;
180     }
181 
182     struct UploadConf
183     {
184         string path;
185         uint maxSize = 4 * 1024 * 1024;
186     }
187 
188     struct DownloadConfig
189     {
190         string path = "downloads";
191     }
192 
193     struct MailSmtpConf
194     {
195         string host;
196         string channel;
197         ushort port;
198         string protocol;
199         string user;
200         string password;
201     }
202 
203     struct MailConf
204     {
205         MailSmtpConf smtp;
206     }
207 
208     struct DbPoolConf
209     {
210         uint maxConnection = 10;
211         uint minConnection = 10;
212         uint timeout = 10000;
213     }
214 
215     struct DBConfig
216     {
217         string url;
218         DbPoolConf pool;
219     }
220 
221     struct DateConf
222     {
223         string format;
224         string timeZone;
225     }
226 
227     struct CornConf
228     {
229         string noon;
230     }
231 
232     struct ServiceConf
233     {
234         string address = "127.0.0.1";
235         ushort port;
236         int workerThreads;
237         string password;
238     }
239 
240     struct RpcConf
241     {
242         bool enabled = true;
243         ServiceConf service;
244     }
245 
246     struct Views
247     {
248         string path = "views/";
249         string ext = ".dhtml";
250     }
251 
252     DBConfig database;
253     ApplicationConf application;
254     SessionConf session;
255     CacheConf cache;
256     HttpConf http;
257     HttpsConf https;
258     RouteConf route;
259     MemcacheConf memcache;
260     RedisConf redis;
261     LogConfig log;
262     UploadConf upload;
263     DownloadConfig download;
264     CornConf cron;
265     DateConf date;
266     MailConf mail;
267     RpcConf rpc;
268     Views view;
269 }