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

Validate the subscription topic on client #1197

Merged
merged 16 commits into from
Nov 18, 2019

Conversation

dmitrykuzmin
Copy link
Contributor

@dmitrykuzmin dmitrykuzmin commented Nov 13, 2019

This PR addresses #1191.

It introduces the TargetMixin which allows to check if the target is valid.

By "valid" we assume the target is of EntityState/EventMessage type and has filters which target existing message fields.

By default, the check is run in TopicBuilder on topic creation. Thus, all "standard" API for topic creation will run the check. But, if the topic is manually created and passed to the SubscriptionService, it should be checked also manually.

For queries, the target validness check is not run, as the mistake in declared type/filters will be revealed at once, removing the need to double check it on the client.

Spine version advances to 1.2.3.

@dmitrykuzmin
Copy link
Contributor Author

@armiol, @dmdashenkov PTAL. The build depends on SpineEventEngine/base#498.

public interface FilterMixin {

@SuppressWarnings("override") // Implemented in the generated code.
FieldPath getFieldPath();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this, you could extend the interface from FilterOrBuilder.

/**
* Checks if the target field is a top-level field.
*/
default boolean fieldIsTopLevel() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, fieldAtTopLevel?

Same below.

* @throws IllegalArgumentException
* if the target field is not present in the type or doesn't satisfy the constraints
*/
default void validateAgainst(TypeUrl targetType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is way too broad. It looks closer to checkCanFilter(TypeUrl targetType). It would be even better if checkCanApplyTo(Target target), but I am not sure that's possible.

* Extends the {@link Target} with validation routines.
*/
@GeneratedMixin
@SuppressWarnings("override") // Methods are implemented in the generated code.
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above on this matter.

@codecov
Copy link

codecov bot commented Nov 15, 2019

Codecov Report

Merging #1197 into master will increase coverage by <.01%.
The diff coverage is 89.55%.

@@             Coverage Diff             @@
##             master   #1197      +/-   ##
===========================================
+ Coverage      91.4%   91.4%   +<.01%     
- Complexity     4214    4231      +17     
===========================================
  Files           545     547       +2     
  Lines         13129   13189      +60     
  Branches        744     749       +5     
===========================================
+ Hits          12000   12055      +55     
- Misses          894     896       +2     
- Partials        235     238       +3

@dmitrykuzmin dmitrykuzmin requested a review from armiol November 15, 2019 16:39
@dmitrykuzmin
Copy link
Contributor Author

@armiol PTAL again.

option java_outer_classname = "EventsProto";
option java_multiple_files = true;

message ClCreateProject {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's misleading that a file called events.proto has one command and one value type in it.

* Extends the {@link Target} with validation routines.
*/
@GeneratedMixin
public interface TargetMixin extends TargetOrBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make the mixin interfaces package-private. If they are public by design, please document the reasons, as usually that is not the case.

Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@dmitrykuzmin LGTM except for the comments by @dmdashenkov.

@dmitrykuzmin dmitrykuzmin merged commit 0e44f74 into master Nov 18, 2019
@dmitrykuzmin dmitrykuzmin deleted the validate-client-subscriptions branch November 18, 2019 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants