You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "Ruhshan (via GitHub)" <gi...@apache.org> on 2023/07/20 10:17:54 UTC
[PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Ruhshan opened a new pull request, #4257:
URL: https://github.com/apache/eventmesh/pull/4257
<!--
### Contribution Checklist
- Name the pull request in the form "[ISSUE #XXXX] Title of the pull request",
where *XXXX* should be replaced by the actual issue number.
Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
- Fill out the template below to describe the changes contributed by the pull request.
That will give reviewers the context they need to do the review.
- Each pull request should address only one issue.
Please do not mix up code from multiple issues.
- Each commit in the pull request should have a meaningful commit message.
- Once all items of the checklist are addressed, remove the above text and this checklist,
leaving only the filled out template below.
(The sections below can be removed for hotfixes of typos)
-->
<!--
(If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Closes #<XXX>`.)
-->
Fixes #4099.
### Motivation
Mentioned file in the issue has some constants that are being used in two different methods. Refactoring was needed to ensure consistency.
### Modifications
Added the constants in separate file and used as import in the file of interest.
### Documentation
- Does this pull request introduce a new feature? ( no)
- If yes, how is the feature documented? (not applicable )
- If a feature is not applicable for documentation, explain why? (it's a refactoring)
- If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#issuecomment-1646604754
## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#4257](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (6f1add9) into [master](https://app.codecov.io/gh/apache/eventmesh/commit/4b994b0308a74de2290103b2ecf95dcd85d41f11?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (4b994b0) will **increase** coverage by `0.09%`.
> The diff coverage is `70.00%`.
> :exclamation: Current head 6f1add9 differs from pull request most recent head 3eb4d00. Consider uploading reports for the commit 3eb4d00 to get more accurate results
```diff
@@ Coverage Diff @@
## master #4257 +/- ##
============================================
+ Coverage 16.75% 16.85% +0.09%
- Complexity 1415 1426 +11
============================================
Files 592 593 +1
Lines 26029 26069 +40
Branches 2384 2399 +15
============================================
+ Hits 4362 4394 +32
- Misses 21230 21232 +2
- Partials 437 443 +6
```
| [Impacted Files](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...he/eventmesh/runtime/boot/EventMeshHTTPServer.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2Jvb3QvRXZlbnRNZXNoSFRUUFNlcnZlci5qYXZh) | `0.52% <0.00%> (ø)` | |
| [.../protocol/http/processor/CreateTopicProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvaHR0cC9wcm9jZXNzb3IvQ3JlYXRlVG9waWNQcm9jZXNzb3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [.../protocol/http/processor/DeleteTopicProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvaHR0cC9wcm9jZXNzb3IvRGVsZXRlVG9waWNQcm9jZXNzb3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...col/http/processor/QuerySubscriptionProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvaHR0cC9wcm9jZXNzb3IvUXVlcnlTdWJzY3JpcHRpb25Qcm9jZXNzb3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ache/eventmesh/runtime/util/HttpResponseUtils.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL3V0aWwvSHR0cFJlc3BvbnNlVXRpbHMuamF2YQ==) | `23.07% <0.00%> (+1.64%)` | :arrow_up: |
| [...apache/eventmesh/runtime/util/ValueComparator.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL3V0aWwvVmFsdWVDb21wYXJhdG9yLmphdmE=) | `25.00% <ø> (ø)` | |
| [...nt/tcp/impl/cloudevent/CloudEventTCPPubClient.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXNka3MvZXZlbnRtZXNoLXNkay1qYXZhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY2xpZW50L3RjcC9pbXBsL2Nsb3VkZXZlbnQvQ2xvdWRFdmVudFRDUFB1YkNsaWVudC5qYXZh) | `6.06% <ø> (ø)` | |
| [...nt/tcp/impl/cloudevent/CloudEventTCPSubClient.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXNka3MvZXZlbnRtZXNoLXNkay1qYXZhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY2xpZW50L3RjcC9pbXBsL2Nsb3VkZXZlbnQvQ2xvdWRFdmVudFRDUFN1YkNsaWVudC5qYXZh) | `5.88% <ø> (ø)` | |
| [...esh/storage/mongodb/constant/MongodbConstants.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXN0b3JhZ2UtcGx1Z2luL2V2ZW50bWVzaC1zdG9yYWdlLW1vbmdvZGIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9zdG9yYWdlL21vbmdvZGIvY29uc3RhbnQvTW9uZ29kYkNvbnN0YW50cy5qYXZh) | `0.00% <ø> (ø)` | |
| [...h/registry/nacos/service/NacosRegistryService.java](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJlZ2lzdHJ5LXBsdWdpbi9ldmVudG1lc2gtcmVnaXN0cnktbmFjb3Mvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9yZWdpc3RyeS9uYWNvcy9zZXJ2aWNlL05hY29zUmVnaXN0cnlTZXJ2aWNlLmphdmE=) | `49.29% <74.28%> (+5.54%)` | :arrow_up: |
| ... and [2 more](https://app.codecov.io/gh/apache/eventmesh/pull/4257?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
... and [14 files with indirect coverage changes](https://app.codecov.io/gh/apache/eventmesh/pull/4257/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "Ruhshan (via GitHub)" <gi...@apache.org>.
Ruhshan commented on code in PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#discussion_r1270710024
##########
eventmesh-storage-plugin/eventmesh-storage-mongodb/src/main/java/org/apache/eventmesh/storage/mongodb/utils/MongodbCloudEventUtil.java:
##########
@@ -29,10 +29,12 @@
import io.cloudevents.SpecVersion;
import io.cloudevents.core.builder.CloudEventBuilder;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.*;
Review Comment:
Thanks for the feedback,
Updated in my last commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "Alonexc (via GitHub)" <gi...@apache.org>.
Alonexc commented on code in PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#discussion_r1270146427
##########
eventmesh-storage-plugin/eventmesh-storage-mongodb/src/main/java/org/apache/eventmesh/storage/mongodb/utils/MongodbCloudEventUtil.java:
##########
@@ -29,10 +29,12 @@
import io.cloudevents.SpecVersion;
import io.cloudevents.core.builder.CloudEventBuilder;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.*;
Review Comment:
checkstyle doesn't seem to support '. *' import.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#discussion_r1270163763
##########
eventmesh-storage-plugin/eventmesh-storage-mongodb/src/main/java/org/apache/eventmesh/storage/mongodb/constant/MongodbConstants.java:
##########
@@ -24,5 +24,14 @@ public class MongodbConstants {
public static final String SEQUENCE_COLLECTION_NAME = "pub_sub_seq";
public static final String SEQUENCE_KEY_FN = "topic";
public static final String SEQUENCE_VALUE_FN = "value";
+ public static final String DOC_KEY_VERSION = "version";
+ public static final String DOC_KEY_DATA = "data";
+ public static final String DOC_KEY_ID = "id";
+ public static final String DOC_KEY_SOURCE = "source";
+ public static final String DOC_KEY_TYPE = "type";
+ public static final String DOC_KEY_DATA_CONTENT_TYPE = "datacontenttype";
+ public static final String DOC_KEY_SUBJECT = "subject";
Review Comment:
```suggestion
public static final String CLOUD_EVENT_DOC_VERSION = "version";
public static final String CLOUD_EVENT_DOC_DATA = "data";
public static final String CLOUD_EVENT_DOC_ID = "id";
public static final String CLOUD_EVENT_DOC_SOURCE = "source";
public static final String CLOUD_EVENT_DOC_TYPE = "type";
public static final String CLOUD_EVENT_DOC_DATACONTENTTYPE = "datacontenttype";
public static final String CLOUD_EVENT_DOC_SUBJECT = "subject";
```
There is no need to add `KEY_` in the middle of constants. Considering their usage in both `convertToCloudEvent` and `convertToDocument` methods, the suggested naming is more readable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "Ruhshan (via GitHub)" <gi...@apache.org>.
Ruhshan commented on code in PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#discussion_r1270707075
##########
eventmesh-storage-plugin/eventmesh-storage-mongodb/src/main/java/org/apache/eventmesh/storage/mongodb/constant/MongodbConstants.java:
##########
@@ -24,5 +24,14 @@ public class MongodbConstants {
public static final String SEQUENCE_COLLECTION_NAME = "pub_sub_seq";
public static final String SEQUENCE_KEY_FN = "topic";
public static final String SEQUENCE_VALUE_FN = "value";
+ public static final String DOC_KEY_VERSION = "version";
+ public static final String DOC_KEY_DATA = "data";
+ public static final String DOC_KEY_ID = "id";
+ public static final String DOC_KEY_SOURCE = "source";
+ public static final String DOC_KEY_TYPE = "type";
+ public static final String DOC_KEY_DATA_CONTENT_TYPE = "datacontenttype";
+ public static final String DOC_KEY_SUBJECT = "subject";
Review Comment:
Thanks for the feedback. Implement in latest commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "Ruhshan (via GitHub)" <gi...@apache.org>.
Ruhshan commented on code in PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#discussion_r1270965044
##########
eventmesh-storage-plugin/eventmesh-storage-mongodb/src/main/java/org/apache/eventmesh/storage/mongodb/utils/MongodbCloudEventUtil.java:
##########
@@ -29,10 +29,19 @@
import io.cloudevents.SpecVersion;
import io.cloudevents.core.builder.CloudEventBuilder;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_DATA;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_DATACONTENTTYPE;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_ID;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_SOURCE;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_SUBJECT;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_TYPE;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_VERSION;
Review Comment:
Thanks for clarifying again. Will definitely use this pattern in future for appropriate scenarios.
And implemented your feedback in the last commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]: Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257#discussion_r1270764706
##########
eventmesh-storage-plugin/eventmesh-storage-mongodb/src/main/java/org/apache/eventmesh/storage/mongodb/utils/MongodbCloudEventUtil.java:
##########
@@ -29,10 +29,19 @@
import io.cloudevents.SpecVersion;
import io.cloudevents.core.builder.CloudEventBuilder;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_DATA;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_DATACONTENTTYPE;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_ID;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_SOURCE;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_SUBJECT;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_TYPE;
+import static org.apache.eventmesh.storage.mongodb.constant.MongodbConstants.CLOUD_EVENT_DOC_VERSION;
Review Comment:
I suggest importing the `MongodbConstants` class only and using Constants.NAME to refer to the constant, which has the advantage of explicitness. Anyone reading the code can immediately understand that the constant NAME comes from the `MongodbConstants` class. This can reduce cognitive overhead and prevent confusion with constants of the same prefix in other classes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4099]Refactor re-used constant's usage from dedicated file (eventmesh)
Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 merged PR #4257:
URL: https://github.com/apache/eventmesh/pull/4257
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org