Add new node to LoadBalancedRSocketMono

Team,

I am trying to use the LoadBalancedRSocketMono to load balance my Server Nodes. I am intending to perform a registration when a new Server node starts to support auto scaling feature. When I investigated this API, I am not able to add new node to the pool, seems to be static. Please help me how I can perform this functionality and correct my understanding as I am new to RSocket.

Thank You and Appreciate your time.

Thanks and Regards
Karthik

Hi Karthik,

When creating a new a new LoadBalancedRSocketMono you pass in a Publisher<? extends Collection> that emits a collection of RSocketSupplier factors. The collection that is emitted is the current collection of RSocketSuppliers that you want to load balance against. In your case an RSocketSupplier could map to a server node. As new servers are scaled up or down the factories stream is should emit the current collection of available servers. This could be a stream like this:

on next: <server1>
on next: <server1, server2>
on next: <server1, server2, server3>
on next: <server2, server3>

What you need to do is create a Publisher that emits a collection of RSocketSuppliers that represents the current collection of servers nodes. As servers come and go the Publisher needs to emit a new list that is the current snapshot of servers.

What are you using for discovering new nodes? I might be able to help with a Publisher<? extends Collection> example or point you in the right direction.

Thanks,
Robert

Thank You @robertroeser. When my server node comes up, it connects to my Rsocket Broker to register on a port with its Service, host and port. Currently I am storing in memory. My application is on SpringBoot and I will call deregister when the application is destroyed. Please help me with a sample that would be helpful. If you have any recommendation on lightweight datastore to save this state would also be of great help.