Skip to content

Commit

Permalink
merge code
Browse files Browse the repository at this point in the history
  • Loading branch information
fanliang11 committed Aug 13, 2019
1 parent ba0ab8e commit 64171a1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
28 changes: 19 additions & 9 deletions src/Surging.Core/Surging.Core.Consul/ConsulServiceRouteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,26 @@ private async Task<List<IDistributedLock>> CreateLock()
var clients = await _consulClientProvider.GetClients();
foreach (var client in clients)
{
var distributedLock = await client.AcquireLock(new LockOptions($"lock_{_configInfo.RoutePath}")
var key = $"lock_{_configInfo.RoutePath}";
var writeResult = await client.KV.Get(key);
if (writeResult.Response!=null)
{
SessionTTL = TimeSpan.FromSeconds(_configInfo.LockDelay),
LockTryOnce = true,
LockWaitTime = TimeSpan.FromSeconds(_configInfo.LockDelay)
}, _configInfo.LockDelay == 0 ?
default :
new CancellationTokenSource(TimeSpan.FromSeconds(_configInfo.LockDelay)).Token);

result.Add(distributedLock);
var distributedLock = await client.AcquireLock(key);
result.Add(distributedLock);
}
else
{
var distributedLock = await client.AcquireLock(new LockOptions($"lock_{_configInfo.RoutePath}")
{
SessionTTL = TimeSpan.FromSeconds(_configInfo.LockDelay),
LockTryOnce = true,
LockWaitTime = TimeSpan.FromSeconds(_configInfo.LockDelay)
}, _configInfo.LockDelay == 0 ?
default :
new CancellationTokenSource(TimeSpan.FromSeconds(_configInfo.LockDelay)).Token);
result.Add(distributedLock);
}

}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Surging.Core.DotNettyWSServer
{
public class DotNettyWSModule : EnginePartModule
{
public override void Initialize(CPlatformContainer serviceProvider)
public override void Initialize(AppModuleContext serviceProvider)
{
base.Initialize(serviceProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Surging.Core.Protocol.Udp
{
public class DnsProtocolModule : EnginePartModule
{
public override void Initialize(CPlatformContainer serviceProvider)
public override void Initialize(AppModuleContext serviceProvider)
{
base.Initialize(serviceProvider);
}
Expand Down
16 changes: 0 additions & 16 deletions src/Surging.Core/Surging.Core.Protocol.Udp/UdpServiceExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,6 @@ private async Task LocalExecuteAsync(UdpServiceEntry entry, byte [] bytes)
}
}


private async Task LocalExecuteAsync(UdpServiceEntry entry, object message)
{
HttpResultMessage<object> resultMessage = new HttpResultMessage<object>();
try
{
await entry.Behavior.Dispatch(message);
}
catch (Exception exception)
{
if (_logger.IsEnabled(LogLevel.Error))
_logger.LogError(exception, "执行本地逻辑时候发生了错误。");
}
}


private async Task SendRemoteInvokeResult(IMessageSender sender, byte[] resultMessage)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Surging": {
"Ip": "${Surging_Server_IP}|127.0.0.1",
"WatchInterval": 30,
"Port": "${Surging_Server_Port}|98",
"Port": "${Surging_Server_Port}|981",
"MappingIp": "${Mapping_ip}",
"MappingPort": "${Mapping_Port}",
"Token": "true",
Expand All @@ -18,10 +18,10 @@
"IsModulePerLifetimeScope": false,
"ReloadOnChange": false,
"Ports": {
"HttpPort": "${HttpPort}|280",
"WSPort": "${WSPort}|96",
"MQTTPort": "${MQTTPort}|97",
"UdpPort": "${UdpPort}|95"
"HttpPort": "${HttpPort}|281",
"WSPort": "${WSPort}|961",
"MQTTPort": "${MQTTPort}|971",
"UdpPort": "${UdpPort}|951"
},
"RequestCacheEnabled": false,
"Packages": [
Expand Down

0 comments on commit 64171a1

Please sign in to comment.