-
Notifications
You must be signed in to change notification settings - Fork 62
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
[MU] Disconnection: the distributed way #5334
Comments
Could we contribute this as part of tmail rather than as part of James? |
I think we need to refactor DisconnectorNotifier first , My suggestion: Define interface Request {
String asString();
}
class MultipleUserRequest implements Request {
private final List<Username> usernames;
@Inject
public MultipleUserRequest(List<Username> usernames) {
this.usernames = usernames;
}
@Override
public String asString() {
return usernames.stream().map(Username::asString).collect(Collectors.joining(",", "[", "]"));
}
}
class AllUsersRequest implements Request {
@Override
public String asString() {
return "[]";
}
} Then the class InVMDisconnectorNotifier implements DisconnectorNotifier {
private final Disconnector disconnector;
@Inject
public InVMDisconnectorNotifier(Disconnector disconnector) {
this.disconnector = disconnector;
}
@Override
public void disconnect(Request request) {
switch (request) {
case MultipleUserRequest multipleUserRequest:
disconnector.disconnect(multipleUserRequest.usernames::contains);
break;
case AllUsersRequest allUsersRequest:
disconnector.disconnect(username -> true);
break;
default:
throw new IllegalStateException("Unexpected value: " + request);
}
}
} And class RabbitMQDisconnectorNotifier implements DisconnectorNotifier {
private final reactor.rabbitmq.Sender sender
@Override
public void disconnect(Request request) {
sender.send(request.asString()....)
}
} |
Agree with this refactoring which would move the code toward a kind of sealed case class. |
In a brand new
server/data/data-rabbitmq
implement a version of theDisconnectorNotifier
leveraging a broadcast thus enabing to call disconnect endpoint only on a single node of the cluster.Follow broadcast best practicces
fanout
QUEUE-TTL
Cc @guimard
The text was updated successfully, but these errors were encountered: