-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* For #1097, server support subscribe service. * For #1097, client support subscribe service. * For #1097, server and client support unsubscribe service.
- Loading branch information
1 parent
4a702f8
commit 3bde282
Showing
24 changed files
with
790 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
api/src/main/java/com/alibaba/nacos/api/naming/remote/request/SubscribeServiceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
* | ||
* 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 com.alibaba.nacos.api.naming.remote.request; | ||
|
||
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants; | ||
|
||
/** | ||
* Nacos naming subscribe service request. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public class SubscribeServiceRequest extends NamingCommonRequest { | ||
|
||
private boolean subscribe; | ||
|
||
private String clusters; | ||
|
||
public SubscribeServiceRequest() { | ||
} | ||
|
||
public SubscribeServiceRequest(String namespace, String serviceName, String clusters, boolean subscribe) { | ||
super(namespace, serviceName, null); | ||
this.clusters = clusters; | ||
this.subscribe = subscribe; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NamingRemoteConstants.SUBSCRIBE_SERVICE; | ||
} | ||
|
||
public String getClusters() { | ||
return clusters; | ||
} | ||
|
||
public void setClusters(String clusters) { | ||
this.clusters = clusters; | ||
} | ||
|
||
public boolean isSubscribe() { | ||
return subscribe; | ||
} | ||
|
||
public void setSubscribe(boolean subscribe) { | ||
this.subscribe = subscribe; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
api/src/main/java/com/alibaba/nacos/api/naming/remote/response/NotifySubscriberResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
* | ||
* 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 com.alibaba.nacos.api.naming.remote.response; | ||
|
||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo; | ||
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants; | ||
import com.alibaba.nacos.api.remote.response.Response; | ||
import com.alibaba.nacos.api.remote.response.ResponseCode; | ||
|
||
/** | ||
* Notify subscriber response. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public class NotifySubscriberResponse extends Response { | ||
|
||
private ServiceInfo serviceInfo; | ||
|
||
public NotifySubscriberResponse() { | ||
} | ||
|
||
private NotifySubscriberResponse(ServiceInfo serviceInfo, String message) { | ||
this.serviceInfo = serviceInfo; | ||
setMessage(message); | ||
} | ||
|
||
public static NotifySubscriberResponse buildSuccessResponse(ServiceInfo serviceInfo) { | ||
return new NotifySubscriberResponse(serviceInfo, "success"); | ||
} | ||
|
||
/** | ||
* Build fail response. | ||
* | ||
* @param message error message | ||
* @return faile response | ||
*/ | ||
public static NotifySubscriberResponse buildFailResponse(String message) { | ||
NotifySubscriberResponse result = new NotifySubscriberResponse(); | ||
result.setErrorCode(ResponseCode.FAIL.getCode()); | ||
result.setMessage(message); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NamingRemoteConstants.NOTIFY_SUBSCRIBER; | ||
} | ||
|
||
public ServiceInfo getServiceInfo() { | ||
return serviceInfo; | ||
} | ||
|
||
public void setServiceInfo(ServiceInfo serviceInfo) { | ||
this.serviceInfo = serviceInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
api/src/main/java/com/alibaba/nacos/api/naming/remote/response/SubscribeServiceResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
* | ||
* 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 com.alibaba.nacos.api.naming.remote.response; | ||
|
||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo; | ||
import com.alibaba.nacos.api.naming.remote.NamingRemoteConstants; | ||
import com.alibaba.nacos.api.remote.response.Response; | ||
|
||
/** | ||
* Nacos naming subscribe service response. | ||
* | ||
* @author xiweng.yy | ||
*/ | ||
public class SubscribeServiceResponse extends Response { | ||
|
||
private ServiceInfo serviceInfo; | ||
|
||
public SubscribeServiceResponse() { | ||
} | ||
|
||
public SubscribeServiceResponse(int resultCode, String message, ServiceInfo serviceInfo) { | ||
super(); | ||
setResultCode(resultCode); | ||
setMessage(message); | ||
this.serviceInfo = serviceInfo; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NamingRemoteConstants.SUBSCRIBE_SERVICE; | ||
} | ||
|
||
public ServiceInfo getServiceInfo() { | ||
return serviceInfo; | ||
} | ||
|
||
public void setServiceInfo(ServiceInfo serviceInfo) { | ||
this.serviceInfo = serviceInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.