본문 바로가기

네트워크 통신

(4)
4. grpc의 여러가지 통신 기법 grpc는 4개의 통신을 지원한다. - unary (1개 request , 1개 respone) - server stream (1개 request, n개 response) - client stream (n개 request, 1개 response) - bi stream (n개 request, n개 response) 그리고 클라이언트에서 4가지 통신을 3가지 방법으로 콜 할 수 있다. - blocking - asyn - future 그러면 모든 통신의 경우의 수는 12가지이다. 하지만 request가 n개 일때는 asyn만 지원하고, response가 n개 일 때는 future을 지원하지 않는다. 따라서 총 7가지가 존재한다. unary server stream client stream bi stream b..
3. spring boot에서 grpc 사용하기 1. server 1) 라이브러리 등록 (pom.xml) - dependecy는 grpc를 사용하기 위한 라이브러리들 - build 부분은 maven으로 proto 파일을 빌드하기 위한 부분 ... net.devh grpc-spring-boot-starter 2.5.1.RELEASE io.grpc grpc-netty-shaded net.devh grpc-client-spring-boot-autoconfigure 2.5.1.RELEASE pom ... kr.motd.maven os-maven-plugin 1.6.1 ... org.xolstice.maven.plugins protobuf-maven-plugin 0.6.1 com.google.protobuf:protoc:3.3.0:exe:${os.detecte..
2. proto3 언어 예시) syntax = "proto3"; message SearchRequest { string query = 1; sint32 page_number = 2; repeated int32 result_per_page = 3; A a = 4; InnerMessage innerMessage = 11; map mapData = 12; reserved 5,6,7~10,13; message InnerMessage { String s1 = 1; } } enum A { option allow_alias = true; v1 = 0; v2 = 1; } Message OutterMessage { SearchRequest.InnerMessage = 1; } service SearchService { rpc Search(Sea..
1. grpc 란 1. 정의 1) 구글에서 개발한 rpc(remote procedure call) 시스템으로 tcp/ip, http2.0 프로토콜을 사용한다. 여기서 rpc란 다른 서버의 서비스를 마치 내부 서비스 콜 하듯 쉽게 콜을 하는 프로토콜이다. 2) 클라 서버간에 통신 데이터 규약을 protocol buffer(protobuf)를 이용해 정의한다. protocol buffer는 .proto 파일에 key-value 형태로 정의하고 protoc로 컴파일한다. message Person { string name = 1; int32 id = 2; bool has_ponycopter = 3; } 2. 장점 1) grpc는 직렬화된 바이트 스트림으로 통신하므로 json 통신보다 통신 속도가 빠르다. 3. 단점 1) jso..