- grpc-protobuf ve grpc-stub bağımlılığı kesin gerekiyor.
- grpc-netty-shaded veya grpc-netty arasındaki farkı bilmiyorum
- Java 9 ve üstü için annotations-api gerekiyor.
Stub Bileşeni
Açıklaması şöyle. Kendi kodumuzu yazarken kullandığımız StreamObserver gibi sınıflar bu bileşenden geliyor.
The Stub layer is what is exposed to most developers and provides type-safe bindings to whatever datamodel/IDL/interface you are adapting. gRPC comes with a plugin to the protocol-buffers compiler that generates Stub interfaces out of .proto files, but bindings to other datamodel/IDL are easy and encouraged.
Transport Bileşeni
Açıklaması şöyle
gRPC comes with three Transport implementations:- The Netty-based transport is the main transport implementation based on Netty. It is for both the client and the server.- The OkHttp-based transport is a lightweight transport based on OkHttp. It is mainly for use on Android and is for client only.- The in-process transport is for when a server is in the same process as the client. It is useful for testing, while also being safe for production use.
Örnek - java 9
Şu satırı dahil ederiz
<dependency><groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>${grpc.version}</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>${grpc.version}</version> </dependency> <dependency> <groupId>jakarta.annotation</groupId> <artifactId>jakarta.annotation-api</artifactId> <version>1.3.5</version> <optional>true</optional> </dependency>
Örnek
Şu satırı dahil ederiz. Burada önemli olan şey grpc-netty. grpc-netty sunucu başlatmak için gerekir.
<dependency><groupId>com.google.protobuf</groupId><artifactId>protobuf-java</artifactId><version>3.6.1</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-netty</artifactId><version>1.30.0</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-protobuf</artifactId><version>1.30.0</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-stub</artifactId><version>1.30.0</version></dependency>
Şu satırı dahil ederiz
<dependency><groupId>io.grpc</groupId><artifactId>grpc-netty-shaded</artifactId><version>1.30.2</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-protobuf</artifactId><version>1.30.2</version></dependency><dependency><groupId>io.grpc</groupId><artifactId>grpc-stub</artifactId><version>1.30.2</version></dependency>
<dependency> <!-- necessary for Java 9+ --> <groupId>org.apache.tomcat</groupId> <artifactId>annotations-api</artifactId> <version>6.0.53</version> <scope>provided</scope> </dependency>
Hiç yorum yok:
Yorum Gönder