Skip to content

Commit

Permalink
添加授权流量信息(未来增加限制)
Browse files Browse the repository at this point in the history
  • Loading branch information
noear committed Oct 2, 2024
1 parent 32bbe38 commit 4073b6b
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.noear.socketd.broker.BrokerFragmentHandler;
import org.noear.socketd.transport.core.Session;
import org.noear.socketd.transport.server.Server;
import org.noear.socketd.transport.server.ServerConfig;
import org.noear.socketd.utils.RunUtils;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Component;
Expand Down Expand Up @@ -46,15 +47,10 @@ public void start() throws Throwable {
proxyServerTcp = SocketD.createServer("sd:tcp")
.config(c -> {
c.port(Solon.cfg().serverPort() + 10000)
.serialSend(true)
.maxMemoryRatio(0.8F)
.streamTimeout(MqProxyConfig.streamTimeout)
.ioThreads(MqProxyConfig.ioThreads)
.codecThreads(MqProxyConfig.codecThreads)
.exchangeThreads(MqProxyConfig.exchangeThreads)
.fragmentHandler(brokerFragmentHandler);

EventBus.publish(c);
configureServer(c);
})
.listen(proxyListener)
.start();
Expand All @@ -65,16 +61,11 @@ public void start() throws Throwable {
proxyServerWs = SocketD.createServer("sd:ws")
.config(c -> {
c.port(Solon.cfg().serverPort() + 10001)
.serialSend(true)
.maxMemoryRatio(0.8F)
.streamTimeout(MqProxyConfig.streamTimeout)
.ioThreads(MqProxyConfig.ioThreads)
.codecThreads(MqProxyConfig.codecThreads)
.exchangeThreads(MqProxyConfig.exchangeThreads)
.exchangeExecutor(proxyServerTcp.getConfig().getExchangeExecutor()) //复用通用执行器
.fragmentHandler(brokerFragmentHandler);

EventBus.publish(c);
configureServer(c);
})
.listen(proxyListener)
.start();
Expand All @@ -92,6 +83,23 @@ public void start() throws Throwable {
FolkMQ.versionName());
}

/**
* 公共配置
* */
private void configureServer(ServerConfig serverConfig) {
serverConfig.serialSend(true)
.maxMemoryRatio(0.8F)
.streamTimeout(MqProxyConfig.streamTimeout);

serverConfig.ioThreads(MqProxyConfig.ioThreads)
.codecThreads(MqProxyConfig.codecThreads);

//serverConfig.trafficLimiter(new TrafficLimiterDefault(LicenceUtils.getGlobal().getTps()));


EventBus.publish(serverConfig);
}

@Override
public void preStop() throws Throwable {
if (proxyListener != null) {
Expand Down

0 comments on commit 4073b6b

Please sign in to comment.