Feature: Add instance metadata spi for registration (#324)
parent
13448920f8
commit
8020e35760
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||
*
|
||||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.discovery.service.callee;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.tencent.cloud.polaris.context.spi.InstanceMetadataProvider;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* custom metadata for instance.
|
||||
*@author lepdou 2022-06-16
|
||||
*/
|
||||
@Component
|
||||
public class CustomMetadata implements InstanceMetadataProvider {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put("k1", "v1");
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegion() {
|
||||
return "shanghai";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getZone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCampus() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
|
||||
*
|
||||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.context.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* Instance's custom metadata, metadata will be register to polaris server.
|
||||
* @author lepdou 2022-06-16
|
||||
*/
|
||||
public interface InstanceMetadataProvider {
|
||||
|
||||
/**
|
||||
* @return the metadata of instance.
|
||||
*/
|
||||
Map<String, String> getMetadata();
|
||||
|
||||
/**
|
||||
* The region of current instance.
|
||||
*
|
||||
* @return the region info.
|
||||
*/
|
||||
String getRegion();
|
||||
|
||||
/**
|
||||
* The zone of current instance.
|
||||
*
|
||||
* @return the zone info.
|
||||
*/
|
||||
String getZone();
|
||||
|
||||
/**
|
||||
* The campus/datacenter of current instance.
|
||||
*
|
||||
* @return the campus or datacenter info.
|
||||
*/
|
||||
String getCampus();
|
||||
}
|
Loading…
Reference in new issue