-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamically configured entity classes
Signed-off-by: hanbingleixue <[email protected]>
- Loading branch information
1 parent
ba3b2c4
commit 96b8056
Showing
6 changed files
with
399 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigInfo.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,48 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. All rights reserved. | ||
* | ||
* 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 io.sermant.backend.entity.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* configuration information | ||
* | ||
* @author zhp | ||
* @since 2024-05-16 | ||
*/ | ||
@Getter | ||
@Setter | ||
public class ConfigInfo { | ||
private String pluginType; | ||
|
||
private String nameSpace; | ||
|
||
private String serviceName; | ||
|
||
private String environment; | ||
|
||
private String appName; | ||
|
||
private String zone; | ||
|
||
private String group; | ||
|
||
private String key; | ||
|
||
private String content; | ||
} |
40 changes: 40 additions & 0 deletions
40
sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigServerInfo.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,40 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. All rights reserved. | ||
* | ||
* 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 io.sermant.backend.entity.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Configuration Center Information | ||
* | ||
* @author zhp | ||
* @since 2024-05-16 | ||
*/ | ||
@Getter | ||
@Setter | ||
public class ConfigServerInfo { | ||
private String serverAddress; | ||
|
||
private String userName; | ||
|
||
private String password; | ||
|
||
private String secretKey; | ||
|
||
private String dynamicConfigType; | ||
} |
114 changes: 114 additions & 0 deletions
114
sermant-backend/src/main/java/io/sermant/backend/entity/config/PluginType.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,114 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. All rights reserved. | ||
* | ||
* 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 io.sermant.backend.entity.config; | ||
|
||
import io.sermant.backend.handler.config.DatabaseWriteProhibitionPluginHandler; | ||
import io.sermant.backend.handler.config.FlowcontrolPluginHandler; | ||
import io.sermant.backend.handler.config.LoadbalancerPluginHandler; | ||
import io.sermant.backend.handler.config.MqConsumeProhibitionPluginHandler; | ||
import io.sermant.backend.handler.config.OtherPluginHandler; | ||
import io.sermant.backend.handler.config.PluginHandler; | ||
import io.sermant.backend.handler.config.RemovalPluginHandler; | ||
import io.sermant.backend.handler.config.RouterPluginHandler; | ||
import io.sermant.backend.handler.config.ServiceRegistryPluginHandler; | ||
import io.sermant.backend.handler.config.SpringBootRegistryPluginHandler; | ||
import io.sermant.backend.handler.config.TagTransmissionPluginHandler; | ||
import lombok.Getter; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Plugin type | ||
* | ||
* @author zhp | ||
* @since 2024-05-16 | ||
*/ | ||
@Getter | ||
public enum PluginType { | ||
/** | ||
* Label routing plugin | ||
*/ | ||
ROUTER("router", new RouterPluginHandler()), | ||
|
||
/** | ||
* Springboot registration plugin | ||
*/ | ||
SPRINGBOOT_REGISTRY("springboot-registry", new SpringBootRegistryPluginHandler()), | ||
|
||
/** | ||
* Register migration plugin | ||
*/ | ||
SERVICE_REGISTRY("service-registry", new ServiceRegistryPluginHandler()), | ||
|
||
/** | ||
* flowcontrol plugin | ||
*/ | ||
FLOW_CONTROL("flowcontrol", new FlowcontrolPluginHandler()), | ||
/** | ||
* Outlier instance removal plugin | ||
*/ | ||
REMOVAL("removal", new RemovalPluginHandler()), | ||
|
||
/** | ||
* Load balancing plugin | ||
*/ | ||
LOADBALANCER("loadbalancer", new LoadbalancerPluginHandler()), | ||
|
||
/** | ||
* Traffic tag transparency plugin | ||
*/ | ||
TAG_TRANSMISSION("tag-transmission", new TagTransmissionPluginHandler()), | ||
|
||
/** | ||
* Message queue prohibited consumption plugin | ||
*/ | ||
MQ_CONSUME_PROHIBITION("mq-consume-prohibition", new MqConsumeProhibitionPluginHandler()), | ||
|
||
/** | ||
* Database write prohibited plugin | ||
*/ | ||
DATABASE_WRITE_PROHIBITION("database-write-prohibition", new DatabaseWriteProhibitionPluginHandler()), | ||
|
||
/** | ||
* other plugin | ||
*/ | ||
OTHER("other", new OtherPluginHandler()); | ||
|
||
private final String pluginName; | ||
|
||
private final PluginHandler handler; | ||
|
||
PluginType(String pluginName, PluginHandler handler) { | ||
this.pluginName = pluginName; | ||
this.handler = handler; | ||
} | ||
|
||
/** | ||
* Obtain plugin type based on plugin name | ||
* | ||
* @param pluginName plugin name | ||
* @return plugin type | ||
*/ | ||
public static Optional<PluginType> getPluginType(String pluginName) { | ||
for (PluginType pluginType : PluginType.values()) { | ||
if (pluginType.pluginName.equals(pluginName)) { | ||
return Optional.of(pluginType); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
sermant-backend/src/main/java/io/sermant/backend/entity/config/Result.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,65 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. All rights reserved. | ||
* | ||
* 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 io.sermant.backend.entity.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* configuration information | ||
* | ||
* @param <R> Result data type | ||
* @author zhp | ||
* @since 2024-05-16 | ||
*/ | ||
@Getter | ||
@Setter | ||
public class Result<R> { | ||
private String code; | ||
|
||
private String message; | ||
|
||
private R data; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param code result code | ||
* @param message result message | ||
*/ | ||
public Result(String code, String message) { | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param code result code | ||
* @param message result message | ||
* @param data result data | ||
*/ | ||
public Result(String code, String message, R data) { | ||
this.code = code; | ||
this.message = message; | ||
this.data = data; | ||
} | ||
|
||
public boolean isSuccess() { | ||
return ResultCodeType.SUCCESS.getCode().equals(this.code); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
sermant-backend/src/main/java/io/sermant/backend/entity/config/ResultCodeType.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,87 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. All rights reserved. | ||
* | ||
* 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 io.sermant.backend.entity.config; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* Result encoding type | ||
* | ||
* @author zhp | ||
* @since 2024-05-16 | ||
*/ | ||
@Getter | ||
public enum ResultCodeType { | ||
/** | ||
* Interface call successful | ||
*/ | ||
SUCCESS("00", "Success."), | ||
|
||
/** | ||
* Unable to establish connection with Configuration Center failed | ||
*/ | ||
CONNECT_FAIL("01", "Unable to establish connection with Configuration Center failed."), | ||
|
||
/** | ||
* Configuration query failed | ||
*/ | ||
QUERY_FAIL("02", "Configuration query failed."), | ||
|
||
/** | ||
* configuration item already exists | ||
*/ | ||
EXISTS("03", "configuration item already exists."), | ||
|
||
/** | ||
* Failed to add configuration | ||
*/ | ||
ADD_FAIL("04", "Failed to add configuration."), | ||
|
||
/** | ||
* Failed to modify configuration | ||
*/ | ||
MODIFY_FAIL("05", "Failed to modify configuration."), | ||
|
||
/** | ||
* Failed to delete configuration | ||
*/ | ||
DELETE_FAIL("06", "Failed to delete configuration."), | ||
|
||
/** | ||
* Configuration does not exist | ||
*/ | ||
NOT_EXISTS("07", "Configuration does not exist."), | ||
|
||
/** | ||
Check failure on line 69 in sermant-backend/src/main/java/io/sermant/backend/entity/config/ResultCodeType.java GitHub Actions / Checkstyle
|
||
* Missing parameter information | ||
*/ | ||
MISS_PARAM("08", "Missing parameter information."), | ||
|
||
/** | ||
* Interface call failed | ||
*/ | ||
FAIL("09", "Failure."); | ||
|
||
private final String code; | ||
|
||
private final String message; | ||
|
||
ResultCodeType(String code, String message) { | ||
this.code = code; | ||
this.message = message; | ||
} | ||
} |
Oops, something went wrong.