mirror of https://github.com/halo-dev/halo
![]() #### What type of PR is this? /kind improvement /area core /milestone 2.17.x #### What this PR does / why we need it: 为启动时同步添加 ListOptions 选项为后续保持 ExtensionMatcher 的纯粹做准备,后续将移除 ExtensionMatcher 中多余的方法声明,只保留 match 方法,最终的结果希望是 ```java @FunctionalInterface public interface ExtensionMatcher { boolean match(Extension extension); } ``` 以前构建 Controller 的写法 ```java public Controller setupWith(ControllerBuilder builder) { return builder .extension(new Post()) .onAddMatcher(DefaultExtensionMatcher.builder(client, Post.GVK) .fieldSelector(FieldSelector.of( equal(Post.REQUIRE_SYNC_ON_STARTUP_INDEX_NAME, TRUE)) ) .build() ) .build(); } ``` 现在的写法 ```java public Controller setupWith(ControllerBuilder builder) { var post = new Post(); return builder .extension(post) // 当有新数据添加时 .onAddMatcher(extension -> "fake-post".equals(extension.getMetadata().getName())) // 使用 syncAllListOptions 作为启动时同步的查询条件过滤不需要的数据 .syncAllListOptions(ListOptions.builder() .fieldQuery(equal(Post.REQUIRE_SYNC_ON_STARTUP_INDEX_NAME, TRUE)) .build() ) .build(); } ``` #### Does this PR introduce a user-facing change? ```release-note 开发者相关:重构 ControllerBuilder 的匹配条件并增加 syncAllListOptions 作为启动时同步的查询条件 ``` |
||
---|---|---|
.. | ||
src | ||
build.gradle |