All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fun.fengwk.convention4j.spring.cloud.starter.nacos.NacosRegistrationOfflineEndpoint Maven / Gradle / Ivy

There is a newer version: 1.1.14
Show newest version
package fun.fengwk.convention4j.spring.cloud.starter.nacos;

import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;

/**
 * @author fengwk
 */
@Slf4j
@Endpoint(id = "offline")
@AllArgsConstructor
public class NacosRegistrationOfflineEndpoint {

    private final NacosAutoServiceRegistration nacosAutoServiceRegistration;

    @WriteOperation
    public EndpointResult offline() {
        try {
            nacosAutoServiceRegistration.stop();
            return new EndpointResult("offline success");
        } catch (Exception ex) {
            log.error("offline failed", ex);
            return new EndpointResult("offline failed");
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy