-
Notifications
You must be signed in to change notification settings - Fork 192
DATACOUCH-955 - Add support for reactive auditing and ReactiveEntityCallbacks. #1102
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
Merged
mikereiche
merged 10 commits into
spring-projects:master
from
jorgerod:datacouch_955_add_enable_reactive_auditing
Apr 6, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3787fcc
Fix indent (#1094)
quaff 24116ae
Update versions to correct values. (#1106)
mikereiche 214b250
Use queryScanConsistency on reactive deleteAll(). (#1108)
mikereiche 521006f
Add QueryCriteria arrayContaining. (#1110)
mikereiche fcfe778
Support enum arguments on repository queries. (#1112)
mikereiche 4a900b8
Support enum parameters to repository queries. (#1111)
mikereiche b0dd3d9
DATACOUCH-955 - Add support for reactive auditing and ReactiveEntityC…
jorgerod f38cebc
Merge branch 'master' of https://github.com/spring-projects/spring-da…
jorgerod 3f72746
Merge branch 'upstream-master' into datacouch_955_add_enable_reactive…
jorgerod e3a021d
Merge branch 'master' into datacouch_955_add_enable_reactive_auditing
mikereiche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/org/springframework/data/couchbase/core/NonReactiveSupportWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2021 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.couchbase.core; | ||
|
||
import org.springframework.data.couchbase.core.mapping.CouchbaseDocument; | ||
|
||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Wrapper of {@link TemplateSupport} methods to adapt them to {@link ReactiveTemplateSupport}. | ||
* | ||
* @author Carlos Espinaco | ||
* @since 4.2 | ||
*/ | ||
public class NonReactiveSupportWrapper implements ReactiveTemplateSupport { | ||
|
||
private final TemplateSupport support; | ||
|
||
public NonReactiveSupportWrapper(TemplateSupport support) { | ||
this.support = support; | ||
} | ||
|
||
@Override | ||
public Mono<CouchbaseDocument> encodeEntity(Object entityToEncode) { | ||
return Mono.fromSupplier(() -> support.encodeEntity(entityToEncode)); | ||
} | ||
|
||
@Override | ||
public <T> Mono<T> decodeEntity(String id, String source, long cas, Class<T> entityClass) { | ||
return Mono.fromSupplier(() -> support.decodeEntity(id, source, cas, entityClass)); | ||
} | ||
|
||
@Override | ||
public Mono<Object> applyUpdatedCas(Object entity, long cas) { | ||
return Mono.fromSupplier(() -> support.applyUpdatedCas(entity, cas)); | ||
} | ||
|
||
@Override | ||
public Mono<Object> applyUpdatedId(Object entity, Object id) { | ||
return Mono.fromSupplier(() -> support.applyUpdatedId(entity, id)); | ||
} | ||
|
||
@Override | ||
public Long getCas(Object entity) { | ||
return support.getCas(entity); | ||
} | ||
|
||
@Override | ||
public String getJavaNameForEntity(Class<?> clazz) { | ||
return support.getJavaNameForEntity(clazz); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this NonReactiveSupportWrapper object the same as template.reactive().support() ?
Then this extra argument to the ReactiveSupport constructors is not necessary.
And the ReactiveTemplateSupport support object in the ReactiveSupport objects is not necessary - they can just use template.support().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mikereiche
In my opinion and following the implementations of other spring-data projects such as spring-data-mongo, I believe that in blocked stack we should launch
EntityCallback
and from the reactive stack we should launchReactiveEntityCallback
.To have that differentiation, there needs to be one path for blocking (
CouchbaseTemplateSupport
) and another path for reactive (ReactiveCouchbaseTemplateSupport
).Also, I think that, additionally, the blocking audit event should be linked to
AuditingEntityCallback
instead ofAuditingEventListener
(this is not in the PR but you could add it).How do you see it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Thanks for the explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This point
Do you want me to add it to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done