optimize NotifySubscriberRequest (#7545)
This commit is contained in:
parent
fb43badea1
commit
cdd83e2117
@ -22,7 +22,7 @@ import com.alibaba.nacos.api.remote.request.ServerRequest;
|
||||
import static com.alibaba.nacos.api.common.Constants.Naming.NAMING_MODULE;
|
||||
|
||||
/**
|
||||
* Notify subscriber response.
|
||||
* Notify subscriber request.
|
||||
*
|
||||
* @author xiweng.yy
|
||||
*/
|
||||
@ -44,22 +44,12 @@ public class NotifySubscriberRequest extends ServerRequest {
|
||||
return NAMING_MODULE;
|
||||
}
|
||||
|
||||
private NotifySubscriberRequest(ServiceInfo serviceInfo, String message) {
|
||||
private NotifySubscriberRequest(ServiceInfo serviceInfo) {
|
||||
this.serviceInfo = serviceInfo;
|
||||
}
|
||||
|
||||
public static NotifySubscriberRequest buildSuccessResponse(ServiceInfo serviceInfo) {
|
||||
return new NotifySubscriberRequest(serviceInfo, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* Build fail response.
|
||||
*
|
||||
* @param message error message
|
||||
* @return fail response
|
||||
*/
|
||||
public static NotifySubscriberRequest buildFailResponse(String message) {
|
||||
return new NotifySubscriberRequest();
|
||||
public static NotifySubscriberRequest buildNotifySubscriberRequest(ServiceInfo serviceInfo) {
|
||||
return new NotifySubscriberRequest(serviceInfo);
|
||||
}
|
||||
|
||||
public ServiceInfo getServiceInfo() {
|
||||
|
@ -39,7 +39,7 @@ public class NamingPushRequestHandlerTest {
|
||||
ServiceInfoHolder holder = mock(ServiceInfoHolder.class);
|
||||
NamingPushRequestHandler handler = new NamingPushRequestHandler(holder);
|
||||
ServiceInfo info = new ServiceInfo("name", "cluster1");
|
||||
Request req = NotifySubscriberRequest.buildSuccessResponse(info);
|
||||
Request req = NotifySubscriberRequest.buildNotifySubscriberRequest(info);
|
||||
//when
|
||||
Response response = handler.requestReply(req);
|
||||
//then
|
||||
|
@ -42,12 +42,12 @@ public class PushExecutorRpcImpl implements PushExecutor {
|
||||
|
||||
@Override
|
||||
public void doPush(String clientId, Subscriber subscriber, PushDataWrapper data) {
|
||||
pushService.pushWithoutAck(clientId, NotifySubscriberRequest.buildSuccessResponse(getServiceInfo(data, subscriber)));
|
||||
pushService.pushWithoutAck(clientId, NotifySubscriberRequest.buildNotifySubscriberRequest(getServiceInfo(data, subscriber)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPushWithCallback(String clientId, Subscriber subscriber, PushDataWrapper data, PushCallBack callBack) {
|
||||
pushService.pushWithCallback(clientId, NotifySubscriberRequest.buildSuccessResponse(getServiceInfo(data, subscriber)),
|
||||
pushService.pushWithCallback(clientId, NotifySubscriberRequest.buildNotifySubscriberRequest(getServiceInfo(data, subscriber)),
|
||||
callBack, GlobalExecutor.getCallbackExecutor());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user