Skip to content

Commit

Permalink
Merge pull request #1529 from hanbingleixue/develop
Browse files Browse the repository at this point in the history
Add entity classes for config management in Backend
  • Loading branch information
Sherlockhan authored May 31, 2024
2 parents 0218446 + 66958e2 commit b110d00
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 0 deletions.
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;
}
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;
}
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;
}
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);
}
}
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;
}
}

0 comments on commit b110d00

Please sign in to comment.