Water 为项目开发、服务治理,提供一站式解决方案(可以理解为微服务架构支持套件)。基于 Solon 框架开发,并支持完整的 Solon Cloud 规范;已在生产环境奔跑了5年。对中小型项目而言,有它便有一切。
功能相当于:consul + rabbitmq + elk + prometheus + openFaas + quartz + 等等,并有机结合在一起。 或者约等于:nacos + rocketmq + PlumeLog + prometheus + magic-api + xxl-job + 等。
对 k8s 友好,支持 ip 漂移、支持 k8s service 映射(通过上游配置,可直接将服务发现为 k8s service 地址)。
| 组件 | 说明 |
|---|---|
| 开发框架 | |
| org.noear:water.client | 框架:Water 客户端 |
| org.noear:water-solon-plugin | 框架:Water 客户端 for solon(也可用于 Spring Boot 项目) |
| 镜像 | |
| noearorg/waterapi:2.10.2 | 镜像:Water 主接口服务 |
| noearorg/watersev:2.10.2 | 镜像:Water 后台服务(健康检测;数据监视;消息派发;定时任务等…) |
| noearorg/wateradmin:2.10.2 | 镜像:Water 管理控制台(支持LDAP登录) |
| noearorg/waterfaas:2.10.2 | 镜像:Water 即时接口服务,提供轻量级FaaS接口服务 |
| noearorg/xwater:2.10.2 | 构建:Water 助理工具 |

地址: https://water.noear.org (账号:demo ;密码:demo )
关键持久化说明:
org.noear water.client 2.10.2
org.noear water-solon-cloud-plugin 2.2.5
solon.app:name: "demo-api"group: "demo"solon.cloud.water:server: "waterapi:9371" #WATER服务地址config:load: "demo.yml" #默认加载的配置
public class DemoApp {public void main(String[] args) {SolonApp app = Solon.start(DemoApp.class, args);}
}//监控服务:之:添加接口性能记录
@Component(index = -999)
public class AppFilter implements Filter {static Logger log = LoggerFactory.getLogger(DemoApp.class);@Overridepublic void doFilter(Context ctx, FilterChain chain) throws Throwable {//1.开始计时(用于计算响应时长)long start = System.currentTimeMillis();try {chain.doFilter(ctx);} catch (Throwable e) {//2.顺带记录个异常log.error("{}",e);} finally {//3.获得接口响应时长long milliseconds = System.currentTimeMillis() - start;CloudClient.metric().addMeter(Solon.cfg().appName(), "path", ctx.pathNew(), milliseconds);}}
}@Configuration
public class DemoConfig {@Beanpublic DataSource db1(@CloudConfig("demoDb") HikariDataSource ds) {//配置一个数据源return ds;}@Beanpublic I18nBundleFactory i18nBundleFactory(){//将国际化服务,切换为云端接口return new CloudI18nBundleFactory();}
}@Slf4j
@Controller
public class DemoController{@CloudConfig(name = "demoDb", autoRefreshed = true) //配置服务的功能(注解模式)DbContext demoDb;@NamiClient //RPC服务发现的功能(注解模式)RockService rockService;@Mapping("/")public void test(){//日志服务:写个日志log.info("你好,日志服务"); //(content)TagsMDC.tag0("demo");log.error("{}\r\n{}","test","你好,日志服务"); //(tag,summary,content)//配置服务:使用配置的数据库上下文进行查询Map map = demoDb.table("water_reg_service").limit(1).selectMap("*");//消息服务:发送消息CloudClient.event().publish(new Event("demo.test", "{\"order_id\":1}")); //(非注解模式)//Rpc发现服务:调用Rpc接口AppModel app = rockService.getAppById(12);}
}//消息订阅:订阅消息并处理(根据:topic 进行订阅)
@Slf4j
@CloudEvent("demo.test")
public class Event_demo_test implements CloudEventHandler {@Overridepublic boolean handle(Event event) throws Exception {//处理消息...log.info("我收到消息:" + event.content());return true;}
}//配置订阅:关注配置的实时更新
@CloudConfig("demoDb")
public class TestConfigHandler implements CloudConfigHandler {@Overridepublic void handle(Config config) {}
}//分布式任务
@CloudJob(name = "demo_test", cron7x = "0 1 * * * ?")
public class Job_test implements CloudJobHandler {@Overridepublic void handle(Context ctx) throws Throwable {//处理任务...log.info("我被调度了");}
}