Note that channelz is not necessarily a debugging tool - it can be used for monitoring use-cases as well. But I do admit that it gives you only a snapshot so you have to keep polling to detect addition/deletion.
I have a better idea: you can use a streaming RPC for both heart-beats and node-down event notification to other nodes. You will have to add some business logic in your streaming RPC server side as follows: - it maintains a list/table of currently active connected clients - on each new serverCall it uses Grpc.TRANSPORT_ATTR_REMOTE_ADDR to get the remote IP (example here <https://github.com/grpc/grpc-java/blob/master/xds/src/main/java/io/grpc/xds/internal/rbac/engine/GrpcAuthorizationEngine.java#L403>) and add it to the list if not already there - if the call gets dropped/disconnected/completed for any reason (receiving onHalfClose() <https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/ServerCall.java#L69>, onCancel() <https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/ServerCall.java#L78> or onComplete() <https://github.com/grpc/grpc-java/blob/master/api/src/main/java/io/grpc/ServerCall.java#L86>) then it implies the node is not alive any more and use the same Grpc. TRANSPORT_ATTR_REMOTE_ADDR trick to get the remote IP to remove that IP from your list and at the same time add an event to an event queue that will be used to inform other nodes of this event (so you do this asynchronously instead of blocking the original thread where you received the serverCall listener event. Hope that helps. On Tuesday, November 1, 2022 at 2:53:41 PM UTC-7 kom...@gmail.com wrote: > Thanks @Sanjay for quick response. > This is more like a debugging tool. If I want to implement something > like this in my grpcServer interface, is it possible to get this info > as part of Channel object itself? > > thanks, > komal > > On Tue, Nov 1, 2022 at 11:32 AM 'sanjay...@google.com' via grpc.io > <grp...@googlegroups.com> wrote: > > > > You can use channelz to get the list of clients for a server. Check out > > > > https://grpc.io/blog/a-short-introduction-to-channelz/ > > > https://github.com/grpc/proposal/blob/master/A14-channelz.md#sockets-and-listen-sockets > > > https://github.com/grpc/grpc-java/blob/master/services/src/main/proto/grpc/channelz/v1/channelz.proto#L428 > > > > Hope that helps. > > > > On Tuesday, November 1, 2022 at 9:47:45 AM UTC-7 kom...@gmail.com wrote: > >> > >> In Cluster-Management, each node has to heartbeat with a server on > regular basis to indicate that it is alive. > >> When the node-A is down, server will detect that and inform other nodes > that node-A is down. > >> > >> In gRPC, clients use Channel to connect to the server and gRPC keeps > the connection alive. But how does Server get the list of clients (nodes) > and which clients are alive etc. > >> > >> I am currently using JAVA but open to any other language binding if > there is a way to implement above very easily. > >> > >> thanks, > >> Komal > >> > >> On Tuesday, November 1, 2022 at 9:31:30 AM UTC-7 sanjay...@google.com > wrote: > >>> > >>> Which gRPC language are you using? Also I am not sure I understand the > session concept for the cluster mgmt use-case. > >>> > >>> There is a gRFC pull request at > https://github.com/grpc/proposal/pull/319 that proposes a cookie based > session affinity but not sure if that addresses your question. > >>> > >>> On Tuesday, November 1, 2022 at 8:02:29 AM UTC-7 kom...@gmail.com > wrote: > >>>> > >>>> Hi, > >>>> > >>>> My grpc server wants to implement simple cluster management where all > nodes connect to my grpc server. > >>>> > >>>> If the node goes down, i want my server to let other nodes know that > a particular node has gone down. > >>>> > >>>> I have written bi-directional streaming api for periodic update. > >>>> I wanted to know is there a way to implement "session" concept for > cluster-mgmt usecase. > >>>> > >>>> thanks, > >>>> komal > > > > -- > > You received this message because you are subscribed to a topic in the > Google Groups "grpc.io" group. > > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/grpc-io/ODXWewW32cg/unsubscribe. > > To unsubscribe from this group and all its topics, send an email to > grpc-io+u...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/3ce9c3d2-8cf8-422b-858a-b476d4318504n%40googlegroups.com > . > -- 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 grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/952271fe-33b8-4793-b883-96d3eb37615dn%40googlegroups.com.