Ejemplo n.º 1
0
 public DotNettyClientFactory(ILoggerFactory loggerFactory, IMessageCodecFactory codecFactory, IMicroExecutor executor = null)
 {
     _codecFactory  = codecFactory;
     _microExecutor = executor;
     _loggerFactory = loggerFactory;
     _logger        = loggerFactory.CreateLogger <DotNettyClientFactory>();
     _bootstrap     = GetBootstrap();
     _clients       = new ConcurrentDictionary <string, Lazy <Task <IMicroClient> > >();
     _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));
         pipeline.AddLast(new MicroMessageHandler(_codecFactory.GetDecoder()));
         pipeline.AddLast(new ClientHandler((context, message) =>
         {
             var messageListener = context.Channel.GetAttribute(ListenerKey).Get();
             var messageSender   = context.Channel.GetAttribute(SenderKey).Get();
             messageListener.OnReceived(messageSender, message);
         }, channel =>
         {
             var k = channel.GetAttribute(ServiceAddressKey).Get();
             _logger.LogDebug($"删除客户端:{k}");
             _clients.TryRemove(k.ToString(), out _);
         }, loggerFactory));
     }));
 }
Ejemplo n.º 2
0
 public HttpClientFactory(ILogger <HttpClientFactory> logger, IHttpClientFactory clientFactory, IMessageCodecFactory codecFactory, IMicroExecutor executor = null)
 {
     _codecFactory  = codecFactory;
     _microExecutor = executor;
     _logger        = logger;
     _clientFactory = clientFactory;
     _clients       = new ConcurrentDictionary <ServiceAddress, Lazy <IMicroClient> >();
 }
Ejemplo n.º 3
0
 public HttpClientMessageSender(ILoggerFactory loggerFactory, IHttpClientFactory clientFactory,
                                IMessageCodecFactory codecFactory, string url, IMessageListener listener)
 {
     _logger          = loggerFactory.CreateLogger <HttpClientMessageSender>();
     _codecFactory    = codecFactory;
     _url             = url;
     _messageListener = listener;
     _clientFactory   = clientFactory;
 }
Ejemplo n.º 4
0
 public DotNettyClientFactory(ILogger <DotNettyClientFactory> logger, IMessageCodecFactory codecFactory, IMicroExecutor executor = null)
 {
     _codecFactory  = codecFactory;
     _microExecutor = executor;
     _logger        = logger;
     _bootstrap     = GetBootstrap();
     _clients       = new ConcurrentDictionary <string, Lazy <IMicroClient> >();
     _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));
         pipeline.AddLast(new MicroMessageHandler(_codecFactory.GetDecoder()));
         pipeline.AddLast(new DefaultChannelHandler(this));
     }));
 }
Ejemplo n.º 5
0
 public HttpMicroListener(IMessageCodecFactory codecFactory)
 {
     _codecFactory = codecFactory;
 }
Ejemplo n.º 6
0
 public DotNettyMicroListener(ILoggerFactory loggerFactory, IMessageCodecFactory codecFactory)
 {
     _loggerFactory = loggerFactory;
     _logger        = loggerFactory.CreateLogger <DotNettyMicroListener>();
     _codecFactory  = codecFactory;
 }
Ejemplo n.º 7
0
 public HttpMicroListener(IMessageCodecFactory codecFactory, IMicroEntryFactory entryFactory, ILoggerFactory loggerFactory)
 {
     _codecFactory = codecFactory;
     _entryFactory = entryFactory;
     _logger       = loggerFactory.CreateLogger <HttpMicroListener>();
 }
Ejemplo n.º 8
0
 public DotNettyMicroListener(ILogger <DotNettyMicroListener> logger, IMessageCodecFactory codecFactory)
 {
     _logger       = logger;
     _codecFactory = codecFactory;
 }