Skip to content

Commit

Permalink
refactor: change data type for observedVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
guqing committed Jan 25, 2024
1 parent 57dfc52 commit aec8dea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static class PostStatus {

private Instant lastModifyTime;

private long observedVersion;
private Long observedVersion;

@JsonIgnore
public ConditionList getConditionsOrDefault() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ public void onApplicationEvent(@NonNull ApplicationContextInitializedEvent event
.setIndexFunc(simpleAttribute(Post.class, post -> {
var version = post.getMetadata().getVersion();
var observedVersion = post.getStatusOrDefault().getObservedVersion();
if (observedVersion == null || observedVersion < version) {
return BooleanUtils.TRUE;
}
// do not care about the false case so return null to avoid indexing
return observedVersion >= version ? BooleanUtils.TRUE : null;
return null;
})));
});
schemeManager.register(Category.class, indexSpecs -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ private String expectListResultJson() {
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "fake-post"
"name": "fake-post",
"version": 1
}
},
"stats": {
Expand Down Expand Up @@ -403,7 +404,8 @@ private String expectListResultJson() {
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "fake-post"
"name": "fake-post",
"version": 1
}
},
"stats": {
Expand Down Expand Up @@ -447,7 +449,8 @@ private String expectListResultJson() {
"apiVersion": "content.halo.run/v1alpha1",
"kind": "Post",
"metadata": {
"name": "fake-post"
"name": "fake-post",
"version": 1
}
},
"stats": {
Expand Down

0 comments on commit aec8dea

Please sign in to comment.