Water(水孕育万物…)
Water 为项目开发、服务治理,提供一站式解决方案(可以理解为微服务架构支持套件)。基于 Solon 框架开发,并支持完整的 Solon Cloud 规范;已在生产环境奔跑了4年。
功能相当于:consul + rabbitmq + elk + prometheus + openFaas + quartz + 等等,并有机结合在一起。 或者约等于:nacos + rocketmq + PlumeLog + prometheus + magic-api + xxl-job + 等。
对 k8s 友好,支持 ip 漂移、支持 k8s service 映射。
本次更新
快速入门
了解开发框架与镜像
组件 | 说明 |
---|
开发框架 | | org.noear:water.client | 框架:Water 客户端 | org.noear:water-solon-plugin | 框架:Water 客户端 for solon(也可用于 Spring Boot 项目) | 镜像 | | noearorg/waterapi:2.6.2 | 镜像:Water 主接口服务 | noearorg/watersev:2.6.2 | 镜像:Water 后台服务(健康检测;数据监视;消息派发;定时任务等…) | noearorg/wateradmin:2.6.2 | 镜像:Water 管理控制台(支持LDAP登录) | noearorg/waterfaas:2.6.2 | 镜像:Water 即时接口服务,提供轻量级FaaS接口服务 | | | noearorg/xwater:2.6.2 | 构建:Water 助理工具 |
控制台演示站
地址: http://water.noear.org (账号:demo ;密码:demo )
关键持久化说明:
- 日志持久化,支持:MySql、PostgreSQL、MongoDb、ElasticSearch、ClickHouse
- 消息持久化,支持:MySql、PostgreSQL、MongoDb
项目地址
- https://gitee.com/noear/water
- https://github.com/noear/water
代码演示
(1) 配置
<dependency>
<groupId>org.noear</groupId>
<artifactId>water.client</artifactId>
<version>${water.ver}</version>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>water-solon-plugin</artifactId>
<version>${solon.ver}</version>
</dependency>
solon.app:
name: "demo-api"
group: "demo"
solon.cloud.water:
server: "waterapi:9371"
config:
load: "demo.yml"
(2) 代码
public class DemoApp {
public void main(String[] args) {
SolonApp app = Solon.start(DemoApp.class, args);
Logger log = LoggerFactory.getLogger(DemoApp.class);
app.filter((ctx, chain) -> {
long start = System.currentTimeMillis();
try {
chain.doFilter(ctx);
} catch (Throwable e) {
log.error("{}",e);
} finally {
long milliseconds = System.currentTimeMillis() - start;
CloudClient.metric().addMeter(Solon.cfg().appName(), "path", ctx.pathNew(), milliseconds);
}
});
}
}
@Configuration
public class DemoConfig {
@Bean
public DataSource db1(@CloudConfig("demoDb") HikariDataSource ds) {
return ds;
}
@Bean
public I18nBundleFactory i18nBundleFactory(){
return new CloudI18nBundleFactory();
}
}
@Slf4j
@Controller
public class DemoController{
@CloudConfig(name = "demoDb", autoRefreshed = true)
DbContext demoDb;
@NamiClient
RockService rockService;
@Mapping("/")
public void test(){
log.info("你好,日志服务");
TagsMDC.tag0("demo");
log.error("{}\r\n{}","test","你好,日志服务");
Map map = demoDb.table("water_reg_service").limit(1).selectMap("*");
CloudClient.event().publish(new Event("demo.test", "{\"order_id\":1}"));
AppModel app = rockService.getAppById(12);
}
}
@Slf4j
@CloudEvent("demo.test")
public class Event_demo_test implements CloudEventHandler {
@Override
public boolean handle(Event event) throws Exception {
log.info("我收到消息:" + event.content());
return true;
}
}
@CloudConfig("demoDb")
public class TestConfigHandler implements CloudConfigHandler {
@Override
public void handle(Config config) {
}
}
@CloudJob(name = "demo_test", cron7x = "0 1 * * * ?")
public class Job_test implements CloudJobHandler {
@Override
public void handle(Context ctx) throws Throwable {
log.info("我被调度了");
}
}
|