One-stop microservice management platform, Water v2.10.4 released

Water (Water breeds all things...)

Water provides a one-stop solution for project development and service governance (which can be understood as a microservice architecture support suite). Developed based on the Solon framework and supports the complete Solon Cloud specification; it has been running in the production environment for 5 years. For small and medium-sized projects, it has everything.

The function is equivalent to: consul + rabbitmq + elk + prometheus + openFaas + quartz + etc., and organically combined. Or approximately equal to: nacos + rocketmq + PlumeLog + prometheus + magic-api + xxl-job + etc.

It is friendly to k8s, supports ip drift, and supports k8s service mapping (through upstream configuration, services can be directly discovered as k8s service addresses).

this update

  • Solon is upgraded to: 2.2.16
  • snack3 upgrade to: 3.2.66
  • Wood is upgraded to: 1.1.1
  • water.client increase the version number as header information upload
  • waterapi increase the version number as header information output
  • When repairing internationalization and exporting json, there will be confusion when there are []
  • Add label to configuration management/application properties as an internal display group
  • Apply Monitoring Adjustment Interval

quick start

Learn about development frameworks and images

components illustrate
Development Framework  
org.noear:water.client Framework: Water client
org.noear:water-solon-plugin Framework: Water client for solon (also available for Spring Boot projects)
mirror image  
noearorg/waterapi:2.10.4 Mirroring: Water main interface service
noearorg/watersev:2.10.4 Mirroring: Water background services (health detection; data monitoring; message dispatch; scheduled tasks, etc...)
noearorg/wateradmin:2.10.4 Mirror image: Water management console (supports LDAP login)
noearorg/waterfaas:2.10.4 Mirror image: Water instant interface service, providing lightweight FaaS interface service
   
noearorg/xwater:2.10.4 Build: Water Assistant Tool

console function

console demo station

Address: https://water.noear.org (account: demo; password: demo)  

Key Persistence Notes:

  • Log persistence, support: MySql, PostgreSQL, MongoDb, ElasticSearch, ClickHouse
  • Message persistence, support: MySql, PostgreSQL, MongoDb

project address

code demo

(1) Configuration

  • pom.xml/mevan-configuration
<!-- 客户端版本 -->
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>water.client</artifactId>
    <version>2.10.4</version>
</dependency>

<!-- solon cloud 集成版本 (也可用于 Spring Boot 项目) -->
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>water-solon-cloud-plugin</artifactId>
    <version>2.2.16</version>
</dependency>
  • app.yml / configuration instructions
solon.app:
  name: "demo-api"
  group: "demo"

solon.cloud.water:
  server: "waterapi:9371"    #WATER服务地址
  config:
    load: "demo.yml"         #默认加载的配置

(2) Code

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);
    @Override
    public 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 {

    @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            //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 {
    @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("我被调度了");
    }
}

Guess you like

Origin www.oschina.net/news/240083/water-2-10-4-released