Skip to content

feat:add tips when calling lossless deregister method. #527

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

Merged
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
Expand Up @@ -36,27 +36,34 @@ public interface LosslessPolicy extends Plugin, SortableAware {

String OFFLINE_PATH = "/offline";

String REPS_TEXT_ONLY_LOCALHOST = "only localhost can call this path";

String REPS_TEXT_NO_ACTION = "no action";

String REPS_TEXT_NO_POLICY = "no policy";

String REPS_TEXT_OK = "ok";

String REPS_TEXT_FAILED = "failed";

/**
* build or modify the instance properties
*
* @param instanceProperties properties, for the callback register to set into instance
*/
void buildInstanceProperties(InstanceProperties instanceProperties);

/**
* do lossless register
* @param instance instance to lossless register
*
* @param instance instance to lossless register
* @param instanceProperties properties, for the callback register to set into instance
*/
void losslessRegister(BaseInstance instance, InstanceProperties instanceProperties);

/**
* do lossless deregister
*
* @param instance instance to lossless deregister
*/
void losslessDeregister(BaseInstance instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.tencent.polaris.api.plugin.lossless.LosslessPolicy;
import com.tencent.polaris.api.plugin.lossless.RegisterStatus;
import com.tencent.polaris.api.pojo.BaseInstance;
import com.tencent.polaris.api.rpc.BaseEntity;
import com.tencent.polaris.api.utils.CollectionUtils;
import com.tencent.polaris.client.pojo.Event;
import com.tencent.polaris.client.util.HttpServerUtils;
Expand Down Expand Up @@ -93,8 +92,8 @@ public void handle(HttpExchange exchange) throws IOException {
InetSocketAddress remoteAddress = exchange.getRemoteAddress();
LOG.info("[LosslessDeregister] received lossless deregister request from {}", remoteAddress);
if (!remoteAddress.getAddress().isLoopbackAddress()) {
exchange.sendResponseHeaders(403, 0);
exchange.close();
LOG.warn("[LosslessDeRegister] only loop-back address (like localhost or 127.0.0.1) can call this path");
HttpServerUtils.writeTextToHttpServer(exchange, REPS_TEXT_ONLY_LOCALHOST, 403);
return;
}
Map<BaseInstance, LosslessActionProvider> actionProviders = valueContext.getValue(LosslessActionProvider.CTX_KEY);
Expand All @@ -106,8 +105,8 @@ public void handle(HttpExchange exchange) throws IOException {

List<LosslessPolicy> losslessPolicies = extensions.getLosslessPolicies();
if (CollectionUtils.isEmpty(losslessPolicies)) {
LOG.warn("lossless is disabled, no losslessDeregister will do");
exchange.sendResponseHeaders(500, 0);
LOG.warn("[LosslessDeRegister] lossless is disabled, no losslessDeregister will do");
HttpServerUtils.writeTextToHttpServer(exchange, REPS_TEXT_NO_POLICY, 500);
exchange.close();
return;
}
Expand Down
Loading