Skip to content

Commit

Permalink
[ISSUE #3952]Optimize EventMeshServer#EventMeshServer method (#3953)
Browse files Browse the repository at this point in the history
* [ISSUE #3952]Optimize EventMeshServer#EventMeshServer method

* add if no protocols are provided, initialize BOOTSTRAP_LIST with default protocols

* set default protocol is tcp

* add default branch
  • Loading branch information
mxsm authored May 30, 2023
1 parent c4a4ff8 commit 3092643
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,39 @@ public class EventMeshServer {
private static final ConfigService configService = ConfigService.getInstance();

public EventMeshServer() {

//Initialize configuration
this.configuration = configService.buildConfigInstance(CommonConfiguration.class);
AssertUtils.notNull(this.configuration, "configuration is null");

//Initialize acl, registry, trace and storageResource
this.acl = Acl.getInstance(this.configuration.getEventMeshSecurityPluginType());
this.registry = Registry.getInstance(this.configuration.getEventMeshRegistryPluginType());

trace = Trace.getInstance(this.configuration.getEventMeshTracePluginType(), this.configuration.isEventMeshServerTraceEnable());
this.storageResource = StorageResource.getInstance(this.configuration.getEventMeshStoragePluginType());

//Initialize BOOTSTRAP_LIST based on protocols provided in configuration
final List<String> provideServerProtocols = configuration.getEventMeshProvideServerProtocols();
for (final String provideServerProtocol : provideServerProtocols) {
if (ConfigurationContextUtil.HTTP.equals(provideServerProtocol)) {
BOOTSTRAP_LIST.add(new EventMeshHttpBootstrap(this));
}
if (ConfigurationContextUtil.TCP.equals(provideServerProtocol)) {
BOOTSTRAP_LIST.add(new EventMeshTcpBootstrap(this));
}
if (ConfigurationContextUtil.GRPC.equals(provideServerProtocol)) {
BOOTSTRAP_LIST.add(new EventMeshGrpcBootstrap(this));
switch (provideServerProtocol) {
case ConfigurationContextUtil.HTTP:
BOOTSTRAP_LIST.add(new EventMeshHttpBootstrap(this));
break;
case ConfigurationContextUtil.TCP:
BOOTSTRAP_LIST.add(new EventMeshTcpBootstrap(this));
break;
case ConfigurationContextUtil.GRPC:
BOOTSTRAP_LIST.add(new EventMeshGrpcBootstrap(this));
break;
default:
//nothing to do
}
}

//If no protocols are provided, initialize BOOTSTRAP_LIST with default protocols
if (BOOTSTRAP_LIST.isEmpty()) {
BOOTSTRAP_LIST.add(new EventMeshTcpBootstrap(this));
}
}

public void init() throws Exception {
Expand Down

0 comments on commit 3092643

Please sign in to comment.