Solon 1.5.67 發佈,增加 GraalVm Native 支持

Solon 已有120個生態擴展插件,此次更新主要爲細節打磨:

  • 添加 solon.extend.graalvm 插件,用於適配 graalvm native image 模式
從此,solon 進入 graalvm native image 的世界。

感謝開發者:@饅頭蟲/瓢蟲,近1個月時間的實驗和適配。
  • 添加 detector-solon-plugin 插件,用於爲健康檢測,增加一批預設的探測器(可選:cpu,disk,jvm,memory,os,qps)
#提供了一批健康探測器(多個以,隔開)
#solon.health.detector: "cpu,os,qps"
solon.health.detector: "cpu"

輸出示例:

#curl http://localhost:8080/healthz
{
  "status": "UP",
  "details": {
    "cpu": {
      "status": "UP",
      "details": {
        "ratio": 53.8
      }
    }
  }
}
  • 添加 solon.extend.hotdev 插件
爲開發過程,修改java代自動重新加載,進行嘗試。
  • 插件 solon.data 的緩存註解 tags 值,支持返回數據做爲模板參數
public class UserService{
    /**
     * 獲取用戶信息
     */
    @Cache(tags = "user_${userId},company_bind_${.company_id}") //使用返回結果的字段:company_id
    public UserDo getUser(Long userId) throws SQLException {
        return userMapper.getUser(userId);
    }
    
    /**
     * 根據companyId批量解綁,同時清除與個企業相關的用戶緩存
     * @return
     * @throws SQLException
     */
    @CacheRemove(tags = "company_bind_${companyId}")
    public int batchUnbindCompany(Long companyId) throws SQLException {
        return userMapper.batchUnbindByCompanyId(companyId);
    }
}
  • 插件 solon.i18n 國際化配置支持 key 級別的 默認配置(之前基於文件)
例:一個 key 在 message_cn_ZH 找不到配置,會到 message_cn 找,再沒有 到 message 打
  • 插件 solon.i18n 增加過濾器,自動爲上下文解析地區
  • 插件 water-solon-plugin 升級 water 2.3.2
  • 內核 @Bean 增加 index;@Component 增加 index。爲特定類型增加位置支持
//例:爲應用過濾器增加位置
//
@Component(index = 1)
public class AppFilterImpl implements Filter {
    @Override
    public void doFilter(Context ctx, FilterChain chain) throws Throwable {
        chain.doFilter(ctx);
    }
}
  • 內核 增加 solon.locale 配置,爲系統提供默認地區配置

關於 Solon

Solon 是一個輕量的Java基礎開發框架。強調,剋制 + 簡潔 + 開放的原則;力求,更小、更快、更自由的體驗。支持:RPC、REST API、MVC、Job、Micro service、WebSocket、Socket 等多種開發模式。短小而精悍!

關於 Solon Cloud

Solon Cloud 是一系列的接口標準和配置規範,相當於DDD模式裏的防腐層概念。是 Solon 的微服務架構模式開發解決方案。

快速瞭解 Solon 的材料:

《Solon 特性簡集,相較於 Springboot 有什麼區別?》

《Solon Cloud 分佈式服務開發套件清單,感覺受與 Spring Cloud 的不同》

《Solon 的想法與架構筆記》

所謂更小:

內核0.1m,最小的接口開發單位0.2m(相較於 Dubbo、Springboot 的依賴包,小到可以乎略不計)

所謂更快:

本機http helloworld測試,Qps可達12萬之多。可參考:《helloworld_wrk_test

所謂更自由:(代碼操控自由)

// 除了註解模式之外,還可以按需手動
//
//手動獲取配置(Props 爲 Properties 增強版)
Props db = Solon.cfg().getProp("db");

//手動獲取容器裏的Bean
UserService userService = Aop.get(UserService.class);

//手動監聽http post請求
Solon.global().post("/user/update", x-> userService.updateById(x.paramMap()));

//手動添加個RPC服務
Solon.global().add("/rpc/", HelloService.class, true);

//手動獲取一個RPC服務消費端
HelloService helloService = Nami.builder().create(HelloService.class);

//手動爲容器添加組件
Aop.wrapAndPut(DemoService.class);

附:項目地址

附:入門示例

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章