@@ -158,7 +158,7 @@ Below are the essential parts of configurations for both server and client proje
158158
159159* Add eureka starter as dependency of your server project together with generated class from `proto` files:
160160
161- [source,gradle]
161+ [source, gradle]
162162.build.gradle
163163----
164164 dependencies {
@@ -171,7 +171,7 @@ Below are the essential parts of configurations for both server and client proje
171171* Configure gRPC server to register itself with Eureka.
172172
173173
174- [source,yaml]
174+ [source, yaml]
175175.bootstrap.yaml
176176----
177177spring:
@@ -192,16 +192,14 @@ eureka:
192192 serviceUrl:
193193 defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/ <3>
194194----
195-
196195<1> Specify the port number the gRPC is listening on.
197196<2> Register the eureka service port to be the same as `grpc.port` so client will know where to send the requests to.
198197<3> Specify the registry URL, so the service will register itself with.
199198
200- d
201- * Expose the gRPC service as part of Spring Boot Application.
202199
200+ * Expose the gRPC service as part of Spring Boot Application.
203201
204- [source,java]
202+ [source, java]
205203.EurekaGrpcServiceApp.java
206204----
207205 @SpringBootApplication
@@ -219,15 +217,14 @@ eureka:
219217 public static void main(String[] args) {
220218 SpringApplication.run(DemoApp.class,args);
221219 }
222-
223220 }
224221----
225222
226223=== gRPC Client Project
227224
228225* Add eureka starter as dependency of your client project together with generated class from `proto` files:
229226
230- [source,gradle]
227+ [source, gradle]
231228.build.gradle
232229----
233230 dependencies {
@@ -247,25 +244,23 @@ eureka:
247244 service-url:
248245 defaultZone: http://${eureka.host:localhost}:${eureka.port:8761}/eureka/ <2>
249246----
250-
251247<1> `false` if this project is not meant to act as a service to another client.
252248<2> Specify the registry URL, so this client will know where to look up the required service.
253249
254- * Use EurekaClient to get the coordinates of gRPC service instance from Eureka.
255250
256251[source,java]
257252.GreeterServiceConsumerApplication.java
258253----
259- @EnableEurekaClient
260- @SpringBootApplication
261- public class GreeterServiceConsumerApplication {
262- public static void main(String[] args) {
263- SpringApplication.run(GreeterServiceConsumerApplication.class, args);
264- }
254+ @EnableEurekaClient
255+ @SpringBootApplication
256+ public class GreeterServiceConsumerApplication {
257+ public static void main(String[] args) {
258+ SpringApplication.run(GreeterServiceConsumerApplication.class, args);
265259 }
260+ }
266261----
267262
268-
263+ * Use EurekaClient to get the coordinates of gRPC service instance from Eureka and consume the service :
269264
270265[source,java]
271266.GreeterServiceConsumer.java
@@ -282,14 +277,15 @@ public class GreeterServiceConsumer {
282277 .usePlaintext(true)
283278 .build(); <2>
284279 final GreeterServiceGrpc.GreeterServiceFutureStub stub = GreeterServiceGrpc.newFutureStub(channel); <3>
285- stub.greet(name);
280+ stub.greet(name); <4>
286281
287282 }
288283}
289284----
290285<1> Get the information about the `my-service-name` instance.
291286<2> Build `channel` accordingly.
292287<3> Create stub using the `channel`.
288+ <4> Invoke the service.
293289
294290
295291
0 commit comments