RunOne
For deployment, ionet supports both multi-service single-process deployment and multi-service multi-process multi-machine deployment. You can switch deployment mode freely without changing code. In daily development, you can work with a monolithic mindset; in production, you can selectively adopt multi-process deployment.
Introduction
RunOne is a launcher used to start external services, logic services, and CenterServer.
This section explains how to start external services and logic services in the same process.
- code 6: create and configure external service.
- code 7: create and configure logic services.
- code 8: startup.
final class OneApplication {
static void main() {
...
new RunOne()
.setAeron(aeron)
.enableCenterServer()
.setExternalServer(ofExternalServer())
.setLogicServerList(listLogic())
.startup();
}
static ExternalServer ofExternalServer() {
var builder = ExternalMapper.builder(ExternalGlobalConfig.externalPort);
builder.setJoinEnum(ExternalJoinEnum.WEBSOCKET);
return builder.build();
}
static List<LogicServer> listLogic() {
return List.of(
new HallLogicServer()
, new RoomLogicServer()
);
}
}
CenterServer
CenterServer is similar to a registry service. Only one should run in the whole architecture.
Even if you start multiple processes, there should still be only one registry center.
- code 5: start registry center.
final class OneApplication {
static void main() {
new RunOne()
...
.enableCenterServer()
.startup();
}
}
Aeron
Aeron is the network communication framework used for internal communication support.
For Aeron advantages, see:
final class OneApplication {
static void main() {
var aeron = new AeronLifecycleManager().getAeron();
new RunOne()
...
.setAeron(aeron)
.startup();
}
}
For Aeron and MediaDriver details, please read the official library documentation.
public class AeronLifecycleManager {
...
private MediaDriver mediaDriver;
private Aeron aeron;
public Aeron getAeron() {
return aeron;
}
}
Example Source Code
see https://github.com/iohao/ionet-examples
path : ionet-cookbook-code
- OneApplication