Commit 23f07acd authored by Ali Saeed's avatar Ali Saeed

Create MyGrpcServer class to implement proto file

parent f65a6c45
package Registration_Discovery;
import io.grpc.stub.StreamObserver;
import org.lognet.springboot.grpc.GRpcService;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.util.*;
@GRpcService
public class MyGrpcServer extends Registration_Discovery.SearchServiceGrpc.SearchServiceImplBase {
@Override
public void search(Registration_Discovery.SearchRequest request, StreamObserver<Registration_Discovery.SearchResponse> responseObserver) {
String searchQuery = request.getQuery();
TreeMap<String,Double> documentsScores = new TreeMap<>();
try {
documentsScores = Leader.start(searchQuery);
} catch (IOException | InterruptedException e)
{
System.out.println("problem in getting Results !!");
throw new RuntimeException(e);
}
Registration_Discovery.SearchResult searchResult = Registration_Discovery.SearchResult.newBuilder()
.putAllResults(documentsScores)
.build();
Registration_Discovery.SearchResponse response = Registration_Discovery.SearchResponse.newBuilder()
.setSearchResult(searchResult)
.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment