This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 78ca5aebf [improve][HIP] HIP-01: Refactoring AbstractCollect (#1930)
78ca5aebf is described below

commit 78ca5aebf3423324050b58ac661dad4b8c567c6f
Author: crossoverJie <[email protected]>
AuthorDate: Fri May 10 14:28:29 2024 +0800

    [improve][HIP] HIP-01: Refactoring AbstractCollect (#1930)
    
    Co-authored-by: tomsun28 <[email protected]>
---
 hip/hip-01.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/hip/hip-01.md b/hip/hip-01.md
new file mode 100644
index 000000000..b2f1fd9e3
--- /dev/null
+++ b/hip/hip-01.md
@@ -0,0 +1,54 @@
+
+
+# HIP-01: Refactoring AbstractCollect
+
+
+# Motivation
+
+In the current situation, almost every collector needs to execute the preCheck 
method (with inconsistent names), and there are also redundant `try-catch` 
statements;
+
+I suggest providing another `preCheck` method for `AbstractCollect` to 
separate the validate logic from the collector's logic, which would make the 
code structure clearer and also facilitate the writing of unit tests.
+
+# Goals
+
+## In Scope
+
+Add a method `preCheck` to `AbstractCollect`.
+
+
+
+
+# Detailed Design
+
+## Design & Implementation Details
+
+Add a method `preCheck` to the 
`org.apache.hertzbeat.collector.collect.AbstractCollect` class:
+
+```java
+public abstract class AbstractCollect {
+
+    /**
+     * @param metrics metric configuration
+     * @throws Exception when validation failed
+     */
+    public abstract void preCheck(Metrics metrics) throws Exception;
+}
+```
+
+Before calling the method 
`org.apache.hertzbeat.collector.collect.AbstractCollect#collect`, call the 
`preCheck` method and catch the exception.
+
+Refactoring all `AbstractCollect` to implement the `preCheck` method.
+
+Supplement the relevant unit tests.
+
+
+
+
+
+# Links
+
+<!--
+Updated afterwards
+-->
+* Mailing List discussion thread: 
https://lists.apache.org/thread/cvvo7xg35fxq7kml5ggdrcdygrx6yvyj
+* Mailing List voting thread: 
https://lists.apache.org/thread/1s7dhrb27qfdx1gsh29dvmo8frjbt619
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to