Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 95dae36

Browse files
committed
init commit
0 parents  commit 95dae36

File tree

152 files changed

+9655
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+9655
-0
lines changed

.gitignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Compiled source #
2+
###################
3+
*.com
4+
*.class
5+
*.dll
6+
*.exe
7+
*.o
8+
*.so
9+
server_log_home_IS_UNDEFINED
10+
11+
# Packages #
12+
############
13+
# it's better to unpack these files and commit the raw source
14+
# git has its own built in compression methods
15+
*.7z
16+
*.dmg
17+
*.gz
18+
*.iso
19+
*.jar
20+
*.rar
21+
*.tar
22+
*.zip
23+
24+
# Logs and databases #
25+
######################
26+
*.log
27+
28+
# OS generated files #
29+
######################
30+
.DS_Store*
31+
ehthumbs.db
32+
#Icon?
33+
Thumbs.db
34+
35+
# Editor Files #
36+
################
37+
*~
38+
*.swp
39+
40+
# Gradle Files #
41+
################
42+
.gradle
43+
44+
# Build output directies
45+
/target
46+
*/target
47+
/build
48+
*/build
49+
/generated-sources
50+
*/generated-sources
51+
*Thunderbolt/core/generated-sources/*
52+
var
53+
logs
54+
55+
.idea
56+
# IntelliJ specific files/directories
57+
out
58+
.idea/*
59+
*.ipr
60+
*.iws
61+
*.iml
62+
atlassian-ide-plugin.xml
63+
64+
# Eclipse specific files/directories
65+
.classpath
66+
.project
67+
.settings
68+
.metadata
69+
.recommenders
70+
71+
# NetBeans specific files/directories
72+
.nbattrs
73+
*.orig
74+
75+
dev.properties
76+
app.properties
77+
78+
data
79+
80+
*.versionsBackup

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Being simple
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<center>![logo.jpg](logo.jpg)</center>
2+
3+
轻量的持久化配置服务
4+
---
5+
6+
[English wiki](README_EN.md)
7+
8+
## 一些特性
9+
10+
+ **轻量级**: 没有复杂的技术和第三方依赖;
11+
12+
+ **可靠存储**: 使用**Redis**作为存储,建议时间**Redis Cluster****Redis Master-Slave** 或者 **Redis Proxy Middleware**等技术保证存储的可靠性;
13+
14+
+ **对等的Server节点**: Server节点的对等性,保证即便某些Server不可用,集群仍能工作;
15+
16+
+ **近似实时更新**: diablo使用**Http长轮询**来保证客户端能及时得到配置更新的通知;
17+
18+
+ **简单的UI**: diablo内嵌了一个简单易用的web界面,叫做**Diablo Tower**;
19+
20+
+ ...
21+
22+
## Quick start
23+
24+
### 安装
25+
26+
+ [下载](https://github.com/ihaolin/diablo/releases)最新的压缩包;
27+
+ 或者通过源码构建:
28+
29+
```bash
30+
mvn clean package -DskipTests
31+
# package located diablo-server/target/diablo-server.tar.gz
32+
```
33+
34+
+ 解压缩包:
35+
36+
```bash
37+
tar zxf diablo-server.tar.gz
38+
ll diablo
39+
bin # the execute scripts
40+
conf # conf dir
41+
lib # dependency libs
42+
```
43+
44+
+ 编辑配置文件**diablo.conf**
45+
46+
```bash
47+
# vim ${DIABLO_HOME}/conf/diablo.conf
48+
# The server bind address
49+
BIND_ADDR=127.0.0.1
50+
51+
# The server listening port
52+
LISTEN_PORT=2143
53+
54+
# The redis host
55+
REDIS_HOST=127.0.0.1
56+
57+
# The redis port
58+
REDIS_PORT=6379
59+
60+
# The log path
61+
LOG_PATH=~/logs/diablo
62+
63+
# The password for Diablo Tower admin
64+
TOWER_PASS=admin
65+
66+
# The inverval(seconds) for checking server's status
67+
CHECK_SERVER_INTERVAL=5
68+
69+
# Enable or disable client api auth
70+
# client must config the appKey, if CLIENT_AUTH=true
71+
CLIENT_AUTH=true
72+
73+
# Java Heap options
74+
JAVA_HEAP_OPTS="-Xms512m -Xmx512m"
75+
```
76+
77+
+ 启动或停止**diablo server**:
78+
79+
```bash
80+
${DIABLO_HOME}/bin/diablo.sh start
81+
${DIABLO_HOME}/bin/diablo.sh stop
82+
${DIABLO_HOME}/bin/diablo.sh restart
83+
```
84+
85+
### 使用 Diablo Tower
86+
87+
+ 启动**diablo server**后,便可通过Http访问**diablo tower**(如[http://127.0.0.1:2143](http://127.0.0.1:2143));
88+
89+
+ 事先准备**应用****配置项**
90+
91+
+ 编辑应用:
92+
93+
![app_edit_en.png](snapshots/app_edit_en.png)
94+
95+
+ 编辑配置项:
96+
97+
![config_edit_en.png](snapshots/config_edit_en.png)
98+
99+
### 集成diablo client到应用中
100+
101+
+ [SimpleDiabloClient](diablo-client/src/main/java/me/hao0/diablo/client/SimpleDiabloClient)(**编程模式**):
102+
103+
+ 添加maven依赖:
104+
105+
```xml
106+
<dependency>
107+
<groupId>me.hao0</groupId>
108+
<artifactId>diablo-client</artifactId>
109+
<version>${version}</version>
110+
</dependency>
111+
```
112+
113+
+ 代码样例:
114+
115+
```java
116+
SimpleDiabloClient client = new SimpleDiabloClient();
117+
client.setAppName("myapp");
118+
client.setAppKey("123456");
119+
client.setServers("127.0.0.1:2143,127.0.0.1:2144");
120+
client.start();
121+
122+
// 获取配置项最新的值
123+
String testConfig = client.get("test_config");
124+
125+
// 获取配置项最新的json对象
126+
MyClass myClass = client.get("test_json", MyClass.class);
127+
128+
client.shutdown();
129+
```
130+
+ 具体见[测试用例](diablo-client/src/test/java/me/hao0/diablo/client/SimpleDiabloClientTests.java).
131+
132+
+ [SpringDiabloClient](diablo-client-spring/src/main/java/me/hao0/diablo/client/SpringDiabloClient)(**Spring注入模式**):
133+
134+
+ 添加maven依赖:
135+
136+
```xml
137+
<dependency>
138+
<groupId>me.hao0</groupId>
139+
<artifactId>diablo-client-spring</artifactId>
140+
<version>${version}</version>
141+
</dependency>
142+
```
143+
144+
+ 配置片段:
145+
146+
```xml
147+
<bean class="me.hao0.diablo.client.SpringDiabloClient">
148+
<property name="appName" value="myapp" />
149+
<property name="appKey" value="123456" />
150+
<property name="servers" value="127.0.0.1:2143,127.0.0.1:2144" />
151+
</bean>
152+
```
153+
154+
+ 添加**diablo配置Bean**到**spring上下文中**, 如:
155+
156+
```java
157+
@Component
158+
public class MyAppConfig implements DiabloConfig {
159+
160+
// 支持基本类型转换
161+
private String activityNo;
162+
private Integer activityChannel;
163+
private Boolean activityStart;
164+
private Float activityRatio;
165+
private Long activityCount;
166+
private Double activityFee;
167+
168+
// 支持普通json对象转换
169+
private TimeInfo timeInfo;
170+
171+
// 支持一级List对象转换
172+
private List<TimeInfo> timeInfos;
173+
174+
// 支持一级Map对象转换
175+
private Map<String, TimeInfo> timeInfoMap;
176+
177+
// getters and setters
178+
}
179+
```
180+
181+
182+
+ 具体见[测试用例](diablo-client-spring/src/test/java/me/hao0/diablo/client/SpringDiabloClientTests.java).
183+
184+
+ 这样一旦你通过**Diablo Tower**修改了对应配置项时,客户端将收到通知。
185+
186+
## 如何成为好人
187+
188+
+ 如果觉得还不错,就请喝咖啡吧:
189+
190+
+ 支付宝:
191+
192+
<img src="alipay.png" width="200">
193+
194+
+ 微信:
195+
196+
<img src="wechat.png" width="200">
197+
198+

0 commit comments

Comments
 (0)