-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nacos config supports fuzzy watch. by [email protected]
- Loading branch information
Showing
32 changed files
with
4,270 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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 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
98 changes: 98 additions & 0 deletions
98
api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractFuzzyListenListener.java
This file contains 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,98 @@ | ||
/* | ||
* Copyright 1999-2023 Alibaba Group Holding Ltd. | ||
* | ||
* 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 | ||
* | ||
* http://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 com.alibaba.nacos.api.config.listener; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* AbstractFuzzyListenListener is an abstract class that provides basic functionality for listening to fuzzy | ||
* configuration changes in Nacos. | ||
* | ||
* @author stone-98 | ||
* @date 2024/3/4 | ||
*/ | ||
public abstract class AbstractFuzzyListenListener extends AbstractListener { | ||
|
||
/** | ||
* Unique identifier for the listener. | ||
*/ | ||
private String uuid; | ||
|
||
/** | ||
* Get the UUID (Unique Identifier) of the listener. | ||
* | ||
* @return The UUID of the listener | ||
*/ | ||
public String getUuid() { | ||
return uuid; | ||
} | ||
|
||
/** | ||
* Set the UUID (Unique Identifier) of the listener. | ||
* | ||
* @param uuid The UUID to be set | ||
*/ | ||
public void setUuid(String uuid) { | ||
this.uuid = uuid; | ||
} | ||
|
||
/** | ||
* Callback method invoked when a fuzzy configuration change event occurs. | ||
* | ||
* @param event The fuzzy configuration change event | ||
*/ | ||
public abstract void onEvent(FuzzyListenConfigChangeEvent event); | ||
|
||
/** | ||
* Receive the configuration information. This method is overridden but does nothing in this abstract class. | ||
* | ||
* @param configInfo The configuration information | ||
*/ | ||
@Override | ||
public void receiveConfigInfo(String configInfo) { | ||
// Do nothing by default | ||
} | ||
|
||
/** | ||
* Compute the hash code for this listener based on its UUID. | ||
* | ||
* @return The hash code value for this listener | ||
*/ | ||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(uuid); | ||
} | ||
|
||
/** | ||
* Compare this listener to the specified object for equality. Two listeners are considered equal if they have the | ||
* same UUID. | ||
* | ||
* @param o The object to compare to | ||
* @return true if the specified object is equal to this listener, false otherwise | ||
*/ | ||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
AbstractFuzzyListenListener that = (AbstractFuzzyListenListener) o; | ||
return Objects.equals(uuid, that.uuid); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
api/src/main/java/com/alibaba/nacos/api/config/listener/FuzzyListenConfigChangeEvent.java
This file contains 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,109 @@ | ||
/* | ||
* Copyright 1999-2023 Alibaba Group Holding Ltd. | ||
* | ||
* 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 | ||
* | ||
* http://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 com.alibaba.nacos.api.config.listener; | ||
|
||
/** | ||
* Represents a fuzzy listening configuration change event. | ||
* | ||
* <p>This event indicates that a change has occurred in a configuration that matches a fuzzy listening pattern. | ||
* | ||
* @author stone-98 | ||
* @date 2024/3/12 | ||
*/ | ||
public class FuzzyListenConfigChangeEvent { | ||
|
||
/** | ||
* The group of the configuration that has changed. | ||
*/ | ||
private String group; | ||
|
||
/** | ||
* The data ID of the configuration that has changed. | ||
*/ | ||
private String dataId; | ||
|
||
/** | ||
* The type of change that has occurred (e.g., "ADD_CONFIG", "DELETE_CONFIG"). | ||
*/ | ||
private String type; | ||
|
||
/** | ||
* Constructs an empty FuzzyListenConfigChangeEvent. | ||
*/ | ||
public FuzzyListenConfigChangeEvent() { | ||
} | ||
|
||
/** | ||
* Constructs a FuzzyListenConfigChangeEvent with the specified parameters. | ||
* | ||
* @param group The group of the configuration that has changed | ||
* @param dataId The data ID of the configuration that has changed | ||
* @param type The type of change that has occurred | ||
*/ | ||
public FuzzyListenConfigChangeEvent(String group, String dataId, String type) { | ||
this.group = group; | ||
this.dataId = dataId; | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* Constructs and returns a new FuzzyListenConfigChangeEvent with the specified parameters. | ||
* | ||
* @param group The group of the configuration that has changed | ||
* @param dataId The data ID of the configuration that has changed | ||
* @param type The type of change that has occurred | ||
* @return A new FuzzyListenConfigChangeEvent instance | ||
*/ | ||
public static FuzzyListenConfigChangeEvent build(String group, String dataId, String type) { | ||
return new FuzzyListenConfigChangeEvent(group, dataId, type); | ||
} | ||
|
||
public String getGroup() { | ||
return group; | ||
} | ||
|
||
public void setGroup(String group) { | ||
this.group = group; | ||
} | ||
|
||
public String getDataId() { | ||
return dataId; | ||
} | ||
|
||
public void setDataId(String dataId) { | ||
this.dataId = dataId; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
/** | ||
* Returns a string representation of the FuzzyListenConfigChangeEvent. | ||
* | ||
* @return A string representation of the event | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "FuzzyListenConfigChangeEvent{" + "group='" + group + '\'' + ", dataId='" + dataId + '\'' + ", type='" | ||
+ type + '\'' + '}'; | ||
} | ||
} |
Oops, something went wrong.