-
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 6f78a1f
Showing
5 changed files
with
343 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
sermant-backend/src/main/java/io/sermant/backend/entity/config/ConfigCenterType.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,45 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. 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; | ||
|
||
/** | ||
* Enum for DynamicConfigType | ||
* | ||
* @author zhp | ||
* @since 2024-05-22 | ||
*/ | ||
public enum ConfigCenterType { | ||
/** | ||
* zookeeper configuration center | ||
*/ | ||
ZOOKEEPER, | ||
|
||
/** | ||
* servicecomb-kie configuration center | ||
*/ | ||
KIE, | ||
|
||
/** | ||
* Nacos configuration center | ||
*/ | ||
NACOS, | ||
|
||
/** | ||
* no configuration center implementation | ||
*/ | ||
NOP; | ||
} |
77 changes: 77 additions & 0 deletions
77
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,77 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. 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 { | ||
/** | ||
* plugin type, the plugin to which the configuration item belongs | ||
*/ | ||
private String pluginType; | ||
|
||
/** | ||
* The namespace to which the configuration item belongs, only used by the nacos configuration center | ||
*/ | ||
private String nameSpace; | ||
|
||
/** | ||
* Service name, when not empty, the configuration item only takes effect on microservices | ||
* with the same service name | ||
*/ | ||
private String serviceName; | ||
|
||
/** | ||
* Environment name, when not empty, the configuration item only takes effect for microservices in that environment | ||
*/ | ||
private String environment; | ||
|
||
/** | ||
* Application name, when not empty, the current configuration item only applies to microservices | ||
* under that application | ||
*/ | ||
private String appName; | ||
|
||
/** | ||
* Zone name, when not empty, the configuration item only applies to microservices in that zone | ||
*/ | ||
private String zone; | ||
|
||
/** | ||
* Grouping name for configuration items | ||
*/ | ||
private String group; | ||
|
||
/** | ||
* The key of the configuration item | ||
*/ | ||
private String key; | ||
|
||
/** | ||
* Configuration Content | ||
*/ | ||
private String content; | ||
} |
55 changes: 55 additions & 0 deletions
55
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,55 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. 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 { | ||
/** | ||
* Configuration Center Address | ||
*/ | ||
private String serverAddress; | ||
|
||
/** | ||
* userName, authentication for Configuration Center | ||
*/ | ||
private String userName; | ||
|
||
/** | ||
* password, authentication for Configuration Center | ||
*/ | ||
private String password; | ||
|
||
/** | ||
* secret key, used for encryption and decryption of passwords | ||
*/ | ||
private String secretKey; | ||
|
||
/** | ||
* Type of Configuration Center | ||
*/ | ||
private String dynamicConfigType; | ||
} |
79 changes: 79 additions & 0 deletions
79
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,79 @@ | ||
/* | ||
* Copyright (C) 2024-2024 Sermant Authors. 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; | ||
|
||
/** | ||
* Result information | ||
* | ||
* @param <R> Result data type | ||
* @author zhp | ||
* @since 2024-05-16 | ||
*/ | ||
@Getter | ||
@Setter | ||
public class Result<R> { | ||
/** | ||
* Result Code, the corresponding enumeration is ResultCodeType | ||
*/ | ||
private String code; | ||
|
||
/** | ||
* Result message | ||
*/ | ||
private String message; | ||
|
||
/** | ||
* Result data | ||
*/ | ||
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; | ||
} | ||
|
||
/** | ||
* Is the result successful | ||
* | ||
* @return true:success false: fail | ||
*/ | ||
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 Sermant Authors. 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 | ||
*/ | ||
CONNECT_FAIL("01", "Unable to establish connection with Configuration Center."), | ||
|
||
/** | ||
* 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."), | ||
|
||
/** | ||
* 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; | ||
} | ||
} |