Velocity icon indicating copy to clipboard operation
Velocity copied to clipboard

Make RegisteredServer implementations stateless

Open roccodev opened this issue 4 years ago • 2 comments

This is a first attempt at solving #566.

This shifts the stateful logic behind VelocityRegisteredServer (keeping track of connected players and sending plugin messages to those players) to a new class (VelocityServerState, backed by the RegisteredServerState API).

This way one could make a custom RegisteredServer that doesn't have to be registered to the proxy, perhaps forwarding the stateful logic to a server that's actually registered. (server aliasing)
For instance, you can now write this:

public class AliasedServer implements RegisteredServer {
    private final RegisteredServer handle;
    private final ServerInfo serverInfo;

    public AliasedServer(RegisteredServer handle, String alias) {
        this.handle = handle;
        this.serverInfo = new ServerInfo(alias, handle.getServerInfo().getAddress());
    }

    @Override
    public ServerInfo getServerInfo() {
        return serverInfo;
    }

    @Override
    public CompletableFuture<ServerPing> ping() {
        return handle.ping();
    }

    @Override
    public RegisteredServerState getState() {
        return handle.getState();
    }
}

This is a breaking API change, but backwards compatibility is kept through deprecated methods.

roccodev avatar Jan 02 '22 21:01 roccodev

What's the status on this? This feature is pretty critical for servers utilizing something like Kubernetes where ip addresses are constantly changing.

XLordalX avatar Jul 22 '22 16:07 XLordalX

What's the status on this? This feature is pretty critical for servers utilizing something like Kubernetes where ip addresses are constantly changing.

I think it's being taken a different way in design - I'm going to write up a UML + draft PR for the overhaul this weekend, see the initial issue in the post, it should be able to be done without any breaking changes at all.

CoreyShupe avatar Jul 23 '22 00:07 CoreyShupe