Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add list options for sync all synchronizer #6145

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

guqing
Copy link
Member

@guqing guqing commented Jun 26, 2024

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 方法,最终的结果希望是

@FunctionalInterface
public interface ExtensionMatcher {
    boolean match(Extension extension);
}

以前构建 Controller 的写法

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();
}

现在的写法

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?

开发者相关:重构 ControllerBuilder 的匹配条件并增加 syncAllListOptions 作为启动时同步的查询条件

@f2c-ci-robot f2c-ci-robot bot added release-note-none Denotes a PR that doesn't merit a release note. kind/improvement Categorizes issue or PR as related to a improvement. labels Jun 26, 2024
@f2c-ci-robot f2c-ci-robot bot added this to the 2.17.x milestone Jun 26, 2024
@f2c-ci-robot f2c-ci-robot bot requested review from ruibaby and wan92hen June 26, 2024 03:28
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Jun 26, 2024
@guqing guqing force-pushed the refactor/sync-list-options branch from 4a76a89 to f285d6c Compare June 26, 2024 04:41
Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 17.39130% with 19 lines in your changes missing coverage. Please review.

Project coverage is 54.75%. Comparing base (5fdf6c0) to head (283a686).
Report is 267 commits behind head on main.

Files Patch % Lines
...n/halo/app/extension/WatcherExtensionMatchers.java 0.00% 8 Missing ⚠️
...lo/app/extension/controller/ControllerBuilder.java 20.00% 6 Missing and 2 partials ⚠️
.../java/run/halo/app/extension/ExtensionMatcher.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6145      +/-   ##
============================================
- Coverage     56.91%   54.75%   -2.16%     
- Complexity     3319     3432     +113     
============================================
  Files           587      630      +43     
  Lines         18968    21198    +2230     
  Branches       1401     1483      +82     
============================================
+ Hits          10795    11607     +812     
- Misses         7594     9001    +1407     
- Partials        579      590      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@guqing guqing force-pushed the refactor/sync-list-options branch from f285d6c to 1d3a415 Compare June 26, 2024 04:59
@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jun 26, 2024
@guqing
Copy link
Member Author

guqing commented Jun 26, 2024

/hold

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 26, 2024
@guqing guqing force-pushed the refactor/sync-list-options branch from 1d3a415 to 283a686 Compare June 26, 2024 06:24
@guqing
Copy link
Member Author

guqing commented Jun 26, 2024

/unhold

@f2c-ci-robot f2c-ci-robot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 26, 2024
Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2024
Copy link

f2c-ci-robot bot commented Jun 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2024
@f2c-ci-robot f2c-ci-robot bot merged commit 3f94cfc into halo-dev:main Jun 26, 2024
7 checks passed
@ruibaby ruibaby modified the milestones: 2.17.x, 2.17.0 Jun 26, 2024
@guqing guqing deleted the refactor/sync-list-options branch June 26, 2024 07:13
f2c-ci-robot bot pushed a commit to halo-dev/docs that referenced this pull request Jun 28, 2024
### What this PR does?
补充关于定制和构建控制器的文档

see also halo-dev/halo#6145

```release-note
None
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/improvement Categorizes issue or PR as related to a improvement. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants