-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss use of ServerList
for Clients
#340
Comments
There are multiple approaches for designing this API and the primary decision point would be whether the interaction with the server list will be asynchronous or synchronous. Before discussing the API, I think it is important to understand that getting a server from this list, should always have an immediate result. There isn't much reason for this list to wait for a server to be available. During the design of ocelli we have determined that a fast-fail behavior in case when no servers are available is the best way to design a load balancer. Asynchronous APIFor the purpose of discussion, this could be the API for the public interface ServerList<T> {
/**
* Chooses the next best server on subscription.
*
* @return An observable, which when subscribed, will return a single item.
*/
Observable<T> choose();
} The advantage of having it designed as an Synchronous APIFor the purpose of discussion, this could be the API for the public interface ServerList<T> {
/**
* Returns the next best server.
*
* @return The next best server.
*
* @throws NoSuchElementException If no items are available.
*/
T next();
} This API is honest to the behavior of a OptimizationsIf the |
seems a little abstract though, right? Is there nothing that could tighten up this context? Originally, I was thinking a 3 tuple like alt-svc of (authority, protocol, socket) as an element of the list. also ServerList is probably not the best name as it isn't a list :) next() ~ Iterator |
oh wait. serverlist scope is authority, so I suppose any structure doesn't need to also pass its authority. |
Apologies for the lack of context. So, here is how I intend this to be used: RxNetty.newTcpClient(serverList).createConnectionRequest(); Inside the Tcp client, assuming serverList.choose().switchMap(socket -> ... bootstrap.connect(socket) ...) (Above is just a representation, not a functional code.) So,
Agreed. I am looking for suggestions :) There are other considerations here about how do we give feedback to the |
PR #366 takes a different approach than discussed in this issue of providing an abstraction of a This approach has these benefits over the approach discussed here:
|
Pre 0.5.0 clients in RxNetty were tied to a specific host and port. With the API changes proposed in #303 and #317 a single HTTP/TCP client can be used for multiple host + port.
The existing API, forced higher level abstractions to be created on top of RxNetty like ribbon to make it usable in a real-world application. The changes in 0.5.0 makes it possible to use RxNetty as a top level abstraction instead of a low level network library.
This issue, is to discuss viability of providing a
ServerList
for a client, which is queried for every connect request on a client.What is a
ServerList
?Instead of initializing a client with a
SocketAddress
as the address for the target server, the client can be initialized with a virtual pool of servers. Then, for everyconnect()
call, the client will query this virtual pool to give a target server back, which will be used for that connect.What is the use?
This abstraction will provide a natural way to integrate various load balancers into RxNetty without changing the interaction model with the client. In absence of this abstraction, any library like ocelli had to create abstractions on top of RxNetty to be able to use a dynamic pool of servers instead of a well defined list of servers.
By providing this abstraction, users would be able to plug in any load balancer into RxNetty and still keep the same API for using a client.
The text was updated successfully, but these errors were encountered: