Skip to content
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

增加一点注释 #319

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task StartAsync(EndPoint endPoint)
IEventLoopGroup bossGroup = new MultithreadEventLoopGroup(1);
IEventLoopGroup workerGroup = new MultithreadEventLoopGroup();//Default eventLoopCount is Environment.ProcessorCount * 2
var bootstrap = new ServerBootstrap();

if (AppConfig.ServerOptions.Libuv)
{
var dispatcher = new DispatcherEventLoopGroup();
Expand All @@ -78,13 +78,14 @@ public async Task StartAsync(EndPoint endPoint)
bossGroup = new MultithreadEventLoopGroup(1);
workerGroup = new MultithreadEventLoopGroup();
bootstrap.Channel<TcpServerSocketChannel>();
}
}
bootstrap
.Option(ChannelOption.SoBacklog, AppConfig.ServerOptions.SoBacklog)
.ChildOption(ChannelOption.Allocator, PooledByteBufferAllocator.Default)
.Group(bossGroup, workerGroup)
.ChildHandler(new ActionChannelInitializer<IChannel>(channel =>
{
//设置数据传输协议和解码器,客户端需一致
var pipeline = channel.Pipeline;
pipeline.AddLast(new LengthFieldPrepender(4));
pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));
Expand Down Expand Up @@ -162,7 +163,7 @@ public override void ExceptionCaught(IChannelHandlerContext context, Exception e
{
context.CloseAsync();//客户端主动断开需要应答,否则socket变成CLOSE_WAIT状态导致socket资源耗尽
if (_logger.IsEnabled(LogLevel.Error))
_logger.LogError(exception,$"与服务器:{context.Channel.RemoteAddress}通信时发送了错误。");
_logger.LogError(exception, $"与服务器:{context.Channel.RemoteAddress}通信时发送了错误。");
}

#endregion Overrides of ChannelHandlerAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public DotNettyTransportClientFactory(ITransportMessageCodecFactory codecFactory
_bootstrap = GetBootstrap();
_bootstrap.Handler(new ActionChannelInitializer<ISocketChannel>(c =>
{
//设置数据传输协议和解码器,与服务端对应
var pipeline = c.Pipeline;
pipeline.AddLast(new LengthFieldPrepender(4));
pipeline.AddLast(new LengthFieldBasedFrameDecoder(int.MaxValue, 0, 4, 0, 4));
Expand Down Expand Up @@ -130,7 +131,7 @@ public void Dispose()
private static Bootstrap GetBootstrap()
{
IEventLoopGroup group;

var bootstrap = new Bootstrap();
if (AppConfig.ServerOptions.Libuv)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,32 @@

namespace Surging.Core.ProxyGenerator.Implementation
{
public class RemoteServiceProxy: ServiceProxyBase
public class RemoteServiceProxy : ServiceProxyBase
{
/// <summary>
/// 远程服务代理,通过RoutePath调用服务时使用
/// 由ServiceProxyProvider调用
/// 通过执行基类的Invoke函数实现远程服务调用
/// </summary>
public RemoteServiceProxy(string serviceKey, CPlatformContainer serviceProvider)
:this(serviceProvider.GetInstances<IRemoteInvokeService>(),
serviceProvider.GetInstances<ITypeConvertibleService>(),serviceKey,serviceProvider,
: this(serviceProvider.GetInstances<IRemoteInvokeService>(),
serviceProvider.GetInstances<ITypeConvertibleService>(), serviceKey, serviceProvider,
serviceProvider.GetInstances<IServiceRouteProvider>())
{

}

public RemoteServiceProxy(IRemoteInvokeService remoteInvokeService,
ITypeConvertibleService typeConvertibleService, String serviceKey,
CPlatformContainer serviceProvider, IServiceRouteProvider serviceRouteProvider
):base(remoteInvokeService, typeConvertibleService, serviceKey, serviceProvider)
) : base(remoteInvokeService, typeConvertibleService, serviceKey, serviceProvider)
{

}

public new async Task<T> Invoke<T>(IDictionary<string, object> parameters, string serviceId)
public new async Task<T> Invoke<T>(IDictionary<string, object> parameters, string serviceId)
{
return await base.Invoke<T>(parameters, serviceId);
return await base.Invoke<T>(parameters, serviceId);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

namespace Surging.Core.ProxyGenerator.Implementation
{
/// <summary>
/// 服务代理生成器
/// </summary>
public class ServiceProxyGenerater : IServiceProxyGenerater,IDisposable
{
#region Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Surging.Core.ProxyGenerator.Implementation
{
/// <summary>
/// 服务代理提供者,通过RoutePath调用服务时使用
/// </summary>
public class ServiceProxyProvider : IServiceProxyProvider
{
private readonly IServiceRouteProvider _serviceRouteProvider;
Expand Down