-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3afafe2
commit e688fd5
Showing
13 changed files
with
157 additions
and
28 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
52 changes: 52 additions & 0 deletions
52
...r/src/main/java/org/serviceplus/broker/register/service/BrokerServiceRegisterService.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,52 @@ | ||
/* | ||
* Copyright 2024 service plus open source organization. | ||
* | ||
* Licensed under the Apache License,Version2.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 org.serviceplus.broker.register.service; | ||
|
||
import io.grpc.stub.StreamObserver; | ||
import org.serviceplus.register.proto.SpServiceRegisterGrpc; | ||
import org.serviceplus.register.proto.SpServiceRegisterOuterClass; | ||
|
||
/** | ||
* @author lixiaoshuang | ||
*/ | ||
public class BrokerServiceRegisterService extends SpServiceRegisterGrpc.SpServiceRegisterImplBase { | ||
@Override | ||
public StreamObserver<SpServiceRegisterOuterClass.ClientRegisterRequest> bidirectionalStreamingMethod(StreamObserver<SpServiceRegisterOuterClass.ServerRegisterRequest> responseObserver) { | ||
StreamObserver<SpServiceRegisterOuterClass.ClientRegisterRequest> streamObserver = new StreamObserver<SpServiceRegisterOuterClass.ClientRegisterRequest>() { | ||
@Override | ||
public void onNext(SpServiceRegisterOuterClass.ClientRegisterRequest clientRegisterRequest) { | ||
boolean b = clientRegisterRequest.hasServiceRegister(); | ||
if (b) { | ||
System.out.println("收到注册服务请求:" + clientRegisterRequest.getServiceRegister().getApplicationName()); | ||
} | ||
} | ||
|
||
@Override | ||
public void onError(Throwable throwable) { | ||
System.out.println("收到注册服务请求异常"); | ||
} | ||
|
||
@Override | ||
public void onCompleted() { | ||
System.out.println("收到注册服务请求完成"); | ||
} | ||
}; | ||
// 向客户端返回调用结果 | ||
SpServiceRegisterOuterClass.ServiceRegisterResponse registerResponse = SpServiceRegisterOuterClass.ServiceRegisterResponse.newBuilder().setMessage("注册服务成功").setCode("200").build(); | ||
responseObserver.onNext(SpServiceRegisterOuterClass.ServerRegisterRequest.newBuilder().setServiceRegisterResponse(registerResponse).build()); | ||
return streamObserver; | ||
} | ||
} |
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
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
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
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
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