On Thursday, June 23, 2022 at 8:45:08 PM UTC+10 Suchismita Sengupta wrote:

> Is multiple services equivalent to multiple servers in golang? 
> I am trying to create a client with multiple servers in grpc in golang.
> Can someone help? I have just started with golang.
>

Think about it as a gRPC server which is capable of hosting one ore more 
gRPC services. When you initialise a gRPC server, you can register one or 
more gRPC services on it and similarly when you write a gRPC client, you 
can communicate with only one or all of the services registered on the gRPC 
server. 

An example of a Go server which registers two services along with some 
tests - they will hopefully help you to write a client as well:

https://github.com/practicalgo/code/tree/master/chap8/multiple-services

Protofbuf: 
https://github.com/practicalgo/code/tree/master/chap8/multiple-services/service
Server and 
tests: 
https://github.com/practicalgo/code/tree/master/chap8/multiple-services/server


 

>
> On Thursday, 20 April 2017 at 05:00:16 UTC+5:30 [email protected] wrote:
>
>> Yes, this should work. 
>>
>>
>> On Monday, April 10, 2017 at 10:39:21 PM UTC-7, [email protected] wrote:
>>>
>>> I have two services in my .proto file and I wonder if I can serve them 
>>> on the same ip:port:
>>>
>>>  lis, _ := net.Listen("tcp", ":8000")
>>>  grpcServer := grpc.NewServer()
>>>  pb.RegisterService1Server(grpcServer, &service1Server{})
>>>  pb.RegisterService2Server(grpcServer, &service2Server{})
>>>  grpcServer.Serve(lis)
>>>
>>> Is this approach ok?
>>>
>>> Also (on a client side) I want to use single connection to a server and 
>>> call method defined in both services:
>>>
>>> conn, _ := grpc.Dial(serverAddr)
>>> cli1 := pb.NewService1Client(conn)
>>> cli2:= pb.NewService2Client(conn)
>>>
>>> Would it work?
>>>
>>> Thanks a lot.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/2bde8a52-9324-438e-aa48-40e1f5e491a3n%40googlegroups.com.

Reply via email to