public TransportClient(IMessageSender messageSender, IMessageListener messageListener, IServiceExecutor serviceExecutor, ILogger logger) { var serviceExecutor1 = serviceExecutor; _messageSender = messageSender; _messageListener = messageListener; _logger = logger; messageListener.Received += async(sender, message) => { if (!_resultDictionary.TryGetValue(message.Id, out var task)) { return; } if (message.IsInvokeResultMessage()) { var content = message.GetContent <RemoteInvokeResultMessage>(); if (!string.IsNullOrEmpty(content.ExceptionMessage)) { task.TrySetException(new RpcRemoteException(content.ExceptionMessage)); } else { task.SetResult(message); } } if (serviceExecutor1 != null && message.IsInvokeMessage()) { await serviceExecutor1.ExecuteAsync(sender, message); } }; }
protected ServiceHostAbstract(IServiceExecutor serviceExecutor) { MessageListener.Received += async(sender, message) => { await serviceExecutor.ExecuteAsync(sender, message); }; }
/// <summary> /// Inject dependent third-party components /// </summary> /// <param name="builder"></param> protected override void RegisterBuilder(ContainerBuilderWrapper builder) { base.RegisterBuilder(builder); builder.Register(provider => { IServiceExecutor serviceExecutor = null; if (provider.IsRegistered(typeof(IServiceExecutor))) { serviceExecutor = provider.Resolve <IServiceExecutor>(); } return(new ThriftTransportClientFactory(provider.Resolve <ITransportMessageCodecFactory>(), provider.Resolve <IHealthCheckService>(), provider.Resolve <ILogger <ThriftTransportClientFactory> >(), serviceExecutor)); }).As(typeof(ITransportClientFactory)).SingleInstance(); builder.Register(provider => { return(new DefaultThriftServiceEntryProvider( provider.Resolve <IServiceEntryProvider>(), provider.Resolve <ILogger <DefaultThriftServiceEntryProvider> >(), provider.Resolve <CPlatformContainer>() )); }).As(typeof(IThriftServiceEntryProvider)).SingleInstance(); if (AppConfig.ServerOptions.Protocol == CommunicationProtocol.Tcp || AppConfig.ServerOptions.Protocol == CommunicationProtocol.None) { RegisterDefaultProtocol(builder); } }
public DotNettyTransportClientFactory(ITransportMessageCodecFactory codecFactory, IHealthCheckService healthCheckService, ILogger <DotNettyTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageEncoder = codecFactory.GetEncoder(); _transportMessageDecoder = codecFactory.GetDecoder(); _logger = logger; _healthCheckService = healthCheckService; _serviceExecutor = serviceExecutor; _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)); if (AppConfig.ServerOptions.EnableHealthCheck) { pipeline.AddLast(new IdleStateHandler(0, AppConfig.ServerOptions.HealthCheckWatchIntervalInSeconds, 0)); pipeline.AddLast(DotNettyConstants.HeartBeatName, new HeartBeatHandler(_healthCheckService, this)); } pipeline.AddLast(DotNettyConstants.TransportMessageAdapterName, new TransportMessageChannelHandlerAdapter(_transportMessageDecoder)); pipeline.AddLast(DotNettyConstants.ClientChannelHandler, new DefaultChannelHandler(this, healthCheckService)); })); }
static void Main(string[] args) { Console.WriteLine("Client, Hello World!"); var host = new ServiceHostBuilder() .RegisterServices(builder => { builder.RegisterType <MessagePackTransportMessageCodecFactory>().As <ITransportMessageCodecFactory>().SingleInstance(); builder.RegisterType(typeof(ClientExecutor)).As(typeof(IServiceExecutor)).SingleInstance(); builder.Register(provider => { IServiceExecutor serviceExecutor = null; if (provider.IsRegistered(typeof(IServiceExecutor))) // 没有注册客户端接收消息执行器,因此一直为空 { serviceExecutor = provider.Resolve <IServiceExecutor>(); } return(new DotNettyTransportClientFactory(provider.Resolve <ITransportMessageCodecFactory>(), provider.Resolve <ILogger <DotNettyTransportClientFactory> >(), serviceExecutor)); }).As(typeof(ITransportClientFactory)).SingleInstance(); }) .UseStartup <Startup>() .Build(); using (host.Run()) { Startup.Test(); } Console.ReadLine(); }
public DotNettyTransportClient(IMessageSender messageSender, IMessageListener messageListener, ILogger logger, IServiceExecutor serviceExecutor) { _messageSender = messageSender; _messageListener = messageListener; _logger = logger; _serviceExecutor = serviceExecutor; messageListener.Received += MessageListener_Received; }
public TransportClient(IMessageSender messageSender, IMessageListener messageListener, ILogger logger, IServiceExecutor serviceExecutor) { _messageSender = messageSender; _messageListener = messageListener; _logger = logger; _serviceExecutor = serviceExecutor; messageListener.Received += MessageListener_Received; }
public DotNettyTransportClientFactory(ISerializer <byte[]> serializer, ISerializer <object> objecSerializer, ILogger <DotNettyTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _serializer = serializer; _objecSerializer = objecSerializer; _logger = logger; _serviceExecutor = serviceExecutor; _bootstrap = GetBootstrap(); }
public ThriftTransportClientFactory(ITransportMessageCodecFactory codecFactory, IHealthCheckService healthCheckService, ILogger <ThriftTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageEncoder = codecFactory.GetEncoder(); _transportMessageDecoder = codecFactory.GetDecoder(); _logger = logger; _healthCheckService = healthCheckService; _serviceExecutor = serviceExecutor; }
public DotNettyTransportClientFactory(ITransportMessageCodecFactory codecFactory, ILogger <DotNettyTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageEncoder = codecFactory.GetEncoder(); _transportMessageDecoder = codecFactory.GetDecoder(); _logger = logger; _serviceExecutor = serviceExecutor; _bootstrap = GetBootstrap(); }
public TransportClient(IMessageSender messageSender, IMessageListener messageListener, ILogger logger, ISerializer <object> objecSerializer, IServiceExecutor serviceExecutor) { _messageSender = messageSender; _messageListener = messageListener; _logger = logger; _objecSerializer = objecSerializer; _serviceExecutor = serviceExecutor; messageListener.Received += MessageListener_Received; }
public RpcClientProxyInterceptor(IServiceIdGenerator serviceIdGenerator, IServiceEntryLocator serviceEntryLocator, ICurrentServiceKey currentServiceKey, IServiceExecutor serviceExecutor) { _serviceIdGenerator = serviceIdGenerator; _serviceEntryLocator = serviceEntryLocator; _currentServiceKey = currentServiceKey; _serviceExecutor = serviceExecutor; }
public TransportClient(IMessageSender messageSender, IMessageListener messageListener, ILogger logger, IServiceExecutor serviceExecutor) { _diagnosticListener = new DiagnosticListener(DiagnosticListenerExtensions.DiagnosticListenerName); _messageSender = messageSender; _messageListener = messageListener; _logger = logger; _serviceExecutor = serviceExecutor; messageListener.Received += MessageListener_Received; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultHttpServiceHost" /> class. /// </summary> /// <param name="messageListenerFactory">The message listener factory.</param> /// <param name="serviceExecutor">The service executor.</param> /// <param name="httpMessageListener">The HTTP message listener.</param> public DefaultHttpServiceHost(Func <EndPoint, Task <IMessageListener> > messageListenerFactory, IServiceExecutor serviceExecutor, HttpMessageListener httpMessageListener) : base(serviceExecutor) { _messageListenerFactory = messageListenerFactory; _serverMessageListener = httpMessageListener; _serverMessageListener.Received += async(sender, message) => { await Task.Run(() => { MessageListener.OnReceived(sender, message); }); }; }
public HttpMessageReceivedHandler(IParameterParser parameterParser, ISerializer serializer, IOptions <RpcOptions> rpcOptions, IServiceExecutor serviceExecutor) : base(parameterParser, serializer, rpcOptions, serviceExecutor) { }
protected MessageReceivedHandlerBase( IParameterParser parameterParser, ISerializer serializer, IOptions <RpcOptions> rpcOptions, IServiceExecutor serviceExecutor) { _parameterParser = parameterParser; _serializer = serializer; _serviceExecutor = serviceExecutor; _rpcOptions = rpcOptions.Value; }
public WsMessageReceivedHandler(IParameterParser parameterParser, ISerializer serializer, IOptions <RpcOptions> rpcOptions, IServiceExecutor serviceExecutor, IRemoteServiceInvoker remoteServiceInvoker, IOptions <GovernanceOptions> governanceOptions) : base(parameterParser, serializer, rpcOptions, serviceExecutor) { }
public MoleculerService(ILogger <MoleculerService> logger, IApplicationLifetime appLifetime, ITransporter transporter, LocalActionServicesLoader localServices, IServiceExecutor executor, IServiceLocator serviceLocator) { _logger = logger; _appLifetime = appLifetime; _transporter = transporter; _localServices = localServices; _executor = executor; _serviceLocator = serviceLocator; _serviceInfo = new ServiceInfo(); FillHostInfo(); }
public DotNettyTransportClientFactory(ITransportMessageCodecFactory codecFactory, ILogger <DotNettyTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageEncoder = codecFactory.GetEncoder(); _transportMessageDecoder = codecFactory.GetDecoder(); _logger = logger; _serviceExecutor = serviceExecutor; _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)); pipeline.AddLast(new TransportMessageChannelHandlerAdapter(_transportMessageDecoder)); pipeline.AddLast(new DefaultChannelHandler(this)); })); }
public DotNettyTransportClientFactory(ITransportMessageCodecFactory codecFactory, ILogger <DotNettyTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageEncoder = codecFactory.GetEncoder(); _transportMessageDecoder = codecFactory.GetDecoder(); _logger = logger; _serviceExecutor = serviceExecutor; //_bootstrap = GetBootstrap(); //_bootstrap.Handler(new ActionChannelInitializer<ISocketChannel>(c => //{ // var pipeline = c.Pipeline; // pipeline.AddLast( // new IdleStateHandler(0, 4, 0), // this.idleStateTrigger, // new ProtocolDecoder(), // encoder, // new TransportMessageChannelHandlerAdapter(_transportMessageDecoder), // new DefaultChannelHandler(this)); //})); }
public static object Create(IServiceExecutor client, Type serviceType) { if (client == null) { throw new ArgumentNullException("client"); } if (!serviceType.IsInterface) { throw new Exception("Only interface allowed."); } var gen = new ProxyGenerator(); var proxy = gen.CreateInterfaceProxyWithoutTarget( serviceType, Type.EmptyTypes, new ServiceActionInterceptor(client, serviceType)); return(proxy); }
public static IServiceBuilder UseDotNettyTransport(this IServiceBuilder builder) { var services = builder.Services; services.Register(provider => { IServiceExecutor serviceExecutor = null; if (provider.IsRegistered(typeof(IServiceExecutor))) { serviceExecutor = provider.Resolve <IServiceExecutor>(); } return(new DotNettyTransportClientFactory(provider.Resolve <ITransportMessageCodecFactory>(), provider.Resolve <ILogger <DotNettyTransportClientFactory> >(), serviceExecutor)); }).As(typeof(ITransportClientFactory)).SingleInstance(); if (AppConfig.ServerOptions.Protocol == CommunicationProtocol.Tcp || AppConfig.ServerOptions.Protocol == CommunicationProtocol.None) { RegisterDefaultProtocol(services); } return(builder); }
public DefaultServiceHost(Func<EndPoint, Task<IMessageListener>> messageListenerFactory, IServiceExecutor serviceExecutor) : base(serviceExecutor) { _messageListenerFactory = messageListenerFactory; }
public ServiceFactoryConvention(IServiceExecutor executor) { _executor = executor; }
public TradeFacade() { this.serviceExecutor = new ServiceExecutor(); }
public SimpleTransportClientFactory(ITransportMessageCodecFactory transportMessageCodecFactory, ILogger<SimpleTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageCodecFactory = transportMessageCodecFactory; _logger = logger; _serviceExecutor = serviceExecutor; }
public CrudEventsExecutor(IServiceExecutor serviceExecutor, Func <string, Type> typeResolver) : base(serviceExecutor, typeResolver) { }
public LoginFacade() { this.serviceExecutor = new ServiceExecutor(); }
public RpcGateway(ServiceStackHost appHost, IServiceExecutor executor) { AppHost = appHost ?? throw new ArgumentNullException(nameof(appHost)); Executor = executor ?? throw new ArgumentNullException(nameof(executor)); }
protected ServiceHostAbstract(IServiceExecutor serviceExecutor) { _serviceExecutor = serviceExecutor; MessageListener.Received += MessageListener_Received; }
public DotNettyServiceHost(IServiceExecutor serviceExecutor, ILogger <DotNettyServiceHost> logger, ISerializer <byte[]> serializer) : base(serviceExecutor) { _logger = logger; _serializer = serializer; }
public ProductListingHandler(ILogger <ProductListingHandler> logger, IServiceExecutor serviceExecutor) { _logger = logger; _serviceExecutor = serviceExecutor; }
public ServiceActionInterceptor(IServiceExecutor executor, Type serviceType) { _executor = executor; _serviceType = serviceType; }
public FileTransfer(IServiceExecutor<IFileTransferService> serviceExecutor) { _serviceExecutor = serviceExecutor; }
public SimpleTransportClientFactory(ITransportMessageCodecFactory transportMessageCodecFactory, ILogger <SimpleTransportClientFactory> logger, IServiceExecutor serviceExecutor) { _transportMessageCodecFactory = transportMessageCodecFactory; _logger = logger; _serviceExecutor = serviceExecutor; }