Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entity classes for config management in Backend #1529

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
lilai23 marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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;
}
}
Loading