public void MergeFrom(ExtAuthz other) { if (other == null) { return; } if (other.FailureModeAllow != false) { FailureModeAllow = other.FailureModeAllow; } switch (other.ServicesCase) { case ServicesOneofCase.GrpcService: if (GrpcService == null) { GrpcService = new global::Envoy.Api.V2.Core.GrpcService(); } GrpcService.MergeFrom(other.GrpcService); break; case ServicesOneofCase.HttpService: if (HttpService == null) { HttpService = new global::Envoy.Config.Filter.Http.ExtAuthz.V2Alpha.HttpService(); } HttpService.MergeFrom(other.HttpService); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public override int GetHashCode() { int hash = 1; if (LogName.Length != 0) { hash ^= LogName.GetHashCode(); } if (grpcService_ != null) { hash ^= GrpcService.GetHashCode(); } if (bufferFlushInterval_ != null) { hash ^= BufferFlushInterval.GetHashCode(); } if (bufferSizeBytes_ != null) { hash ^= BufferSizeBytes.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void MergeFrom(CommonGrpcAccessLogConfig other) { if (other == null) { return; } if (other.LogName.Length != 0) { LogName = other.LogName; } if (other.grpcService_ != null) { if (grpcService_ == null) { GrpcService = new global::Envoy.Api.V2.Core.GrpcService(); } GrpcService.MergeFrom(other.GrpcService); } if (other.bufferFlushInterval_ != null) { if (bufferFlushInterval_ == null) { BufferFlushInterval = new global::Google.Protobuf.WellKnownTypes.Duration(); } BufferFlushInterval.MergeFrom(other.BufferFlushInterval); } if (other.bufferSizeBytes_ != null) { if (bufferSizeBytes_ == null || other.BufferSizeBytes != 0) { BufferSizeBytes = other.BufferSizeBytes; } } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public ClientLogic(string operationsFilePath, string username, string serverHost, int serverPort, string clientHost, int clientPort, string[] partitions, bool useAdvanced) { _operationsFilePath = operationsFilePath; _grpcService = new GrpcService(serverHost, serverPort, this, useAdvanced); _nodeServer = new ClientNodeServer(clientHost, clientPort, username, ServerCredentials.Insecure); ParsePartitions(new List <string>(partitions)); }
// GET: Home public ActionResult Index() { //var dnsQuery = new DnsQuery("sms._grpc._tcp.kmb.home", DnsRecordType.SRV); //var dnsEntries = dnsQuery.Resolve().Result; //var svcName = new ServiceDnsName {DnsName = "sms._grpc._tcp.kmb.home"}; //var srv = ServiceLookup.Srv(svcName, SvcFactory).Task.Result; GrpcService service = _locator.Locate("sms", ChannelCredentials.Insecure).Result; return(View("Index", service)); }
public void GrpcServiceCanBeResolvedFromServiceProvider() { var service = new GrpcService(); var mockServiceProvider = new Mock <IServiceProvider>(); mockServiceProvider .Setup(sp => sp.GetService(typeof(GrpcService))) .Returns(service); Assert.AreSame(service, new DefaultGrpcServiceActivator <GrpcService>(mockServiceProvider.Object).Create()); }
public void Execute(GrpcService grpcService) { Console.WriteLine("Begin Repeat: \n"); for (var i = 1; i <= _numberOfRepeats; ++i) { var counter = i.ToString(); _commands.ForEach(cmd => { cmd = cmd.Replace(ReplaceSymbol, counter); var command = ClientCommands.GetCommand(cmd); command.Execute(grpcService); }); } }
public static void Main(string[] args) { Server server = new Server { Services = { GrpcService.BindService(new GrpcImpl()) }, Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("GrpcService server listening on port " + Port); Console.WriteLine("任意键退出..."); Console.ReadKey(); server.ShutdownAsync().Wait(); }
public void Create_ResolvedFromServiceProvider_NotCreatedByActivator() { // Arrange var service = new GrpcService(); var mockServiceProvider = new Mock <IServiceProvider>(); mockServiceProvider .Setup(sp => sp.GetService(typeof(GrpcService))) .Returns(service); // Act var handle = new DefaultGrpcServiceActivator <GrpcService>().Create(mockServiceProvider.Object); // Assert Assert.AreSame(service, handle.Instance); Assert.IsFalse(handle.Created); }
public void Execute(GrpcService grpcService) { Console.WriteLine($"List Server [{_serverId}]: \n"); var response = grpcService.ListServer(_serverId); foreach (var result in response) { if (result.IsMaster) { Console.WriteLine( $"Server {_serverId} is master with object [{result.ObjectId},{result.ObjectValue}]"); } else { Console.WriteLine($"Server {_serverId} contains object [{result.ObjectId},{result.ObjectValue}]"); } } }
public async Task GrpcService_B_Test() { var locator = new GrpcLocator(); Console.WriteLine("Testing in {0}", locator.ServiceDomain); GrpcService svc = await locator.Locate("alpha-users", ChannelCredentials.Insecure); Assert.IsNotNull(svc); Assert.AreEqual(1, svc.Endpoints.Count); foreach (GrpcEndpoint ep in svc.Endpoints) { Console.WriteLine(ep); } Assert.AreEqual("vrdswarm11.rnd.ipzo.net:7014", svc.Endpoints[0].ToString()); Assert.IsTrue(svc.Expires < DateTime.UtcNow.AddMinutes(1)); }
/// <summary> /// 构造 /// </summary> /// <param name="Services"></param> /// <param name="endpointStrategy"></param> public ClientFactory( #if NETCORE IOptionsMonitor <List <GrpcService> > Services , IEndpointStrategy endpointStrategy #endif ) { _name = $"{typeof(T).DeclaringType.FullName}"; List <GrpcService> services; #if NETCORE services = Services.CurrentValue; _endpointStrategy = endpointStrategy; #else services = GrpcServiceWrapper.Services; _endpointStrategy = CommonUtilsHelper._.EndpointStrategy; #endif _grpcService = services.FirstOrDefault(s => s.Name == _name); }
public override int GetHashCode() { int hash = 1; if (serviceSpecifierCase_ == ServiceSpecifierOneofCase.ClusterName) { hash ^= ClusterName.GetHashCode(); } if (serviceSpecifierCase_ == ServiceSpecifierOneofCase.GrpcService) { hash ^= GrpcService.GetHashCode(); } hash ^= (int)serviceSpecifierCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static async Task<Channel> GetChannelAsync(string serviceName) { string hostName = serviceName; if (!string.IsNullOrEmpty(hostName)) { if (hostName[0] == '@') { GrpcService service = await _locator.Locate(hostName.Substring(1), ChannelCredentials.Insecure); return await service.Connect(TimeSpan.FromSeconds(2)); } var uri = new Uri(hostName); var channel = new Channel(uri.Host, uri.Port, ChannelCredentials.Insecure); //await channel.ConnectAsync(DateTime.UtcNow.AddSeconds(15)); return channel; } throw new ArgumentException($"Service name does not appear in the configuration: {serviceName}", nameof(serviceName)); }
public async Task GrpcService_Exec_Test() { var locator = new GrpcLocator(); Console.WriteLine("Testing in {0}", locator.ServiceDomain); GrpcService svc = await locator.Locate("alpha-users", ChannelCredentials.Insecure); Assert.IsNotNull(svc); HealthCheckResponse reply = await svc.Execute(async channel => { var client = new Health.HealthClient(channel); return(await client.CheckAsync(new HealthCheckRequest { Service = "users" })); }, TimeSpan.FromSeconds(2)); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.Serving, reply.Status); }
/// <summary> /// 构造方法 /// </summary> /// <param name="requestHandler">请求消息处理方法</param> /// <param name="port">监听端口</param> /// <param name="host">监听地址</param> /// <param name="options">设置项,如果为空,则自动设置最大发送和接收数据大小为2147483647字节</param> internal GrpcServer(IGrpcMessageHandler messageHandler, int port, string host = "0.0.0.0", List <ChannelOption> options = null) { if (messageHandler == null) { throw new Exception("GrpcMessageHandler is null"); } this.serviceMessageHandler = new GrpcServiceMessageHandler(messageHandler); if (options == null) { options = new List <ChannelOption>(); options.Add(new ChannelOption(ChannelOptions.MaxSendMessageLength, int.MaxValue)); options.Add(new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue)); } this.grpcServer = new Server(options) { Services = { GrpcService.BindService(this.serviceMessageHandler) }, Ports = { new ServerPort(host, port, ServerCredentials.Insecure) } }; }
public override int GetHashCode() { int hash = 1; if (StatPrefix.Length != 0) { hash ^= StatPrefix.GetHashCode(); } if (grpcService_ != null) { hash ^= GrpcService.GetHashCode(); } if (FailureModeAllow != false) { hash ^= FailureModeAllow.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void Execute(GrpcService grpcService) { Console.WriteLine("List Global: \n"); var response = grpcService.ListGlobal(); foreach (var wrapperRes in response) { Console.WriteLine("List server for server: " + wrapperRes.Key); foreach (var result in wrapperRes.Value) { if (result.IsMaster) { Console.WriteLine( $"Server {wrapperRes.Key} is master with object [{result.ObjectId},{result.ObjectValue}]"); } else { Console.WriteLine( $"Server {wrapperRes.Key} contains object [{result.ObjectId},{result.ObjectValue}]"); } } } /* * string finalResult =""; * * foreach (var result in response) * { * * finalResult += $" Partition {result.PartitionId} has: \n"; * foreach(var objResult in result.ObjectIds) * { * finalResult += $" \t {objResult} \n"; * } * finalResult += "\n"; * } * Console.Write(finalResult); */ }
public override int GetHashCode() { int hash = 1; if (servicesCase_ == ServicesOneofCase.GrpcService) { hash ^= GrpcService.GetHashCode(); } if (servicesCase_ == ServicesOneofCase.HttpService) { hash ^= HttpService.GetHashCode(); } if (FailureModeAllow != false) { hash ^= FailureModeAllow.GetHashCode(); } hash ^= (int)servicesCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void MergeFrom(RateLimitServiceConfig other) { if (other == null) { return; } switch (other.ServiceSpecifierCase) { case ServiceSpecifierOneofCase.ClusterName: ClusterName = other.ClusterName; break; case ServiceSpecifierOneofCase.GrpcService: if (GrpcService == null) { GrpcService = new global::Envoy.Api.V2.Core.GrpcService(); } GrpcService.MergeFrom(other.GrpcService); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public void MergeFrom(ExtAuthz other) { if (other == null) { return; } if (other.StatPrefix.Length != 0) { StatPrefix = other.StatPrefix; } if (other.grpcService_ != null) { if (grpcService_ == null) { GrpcService = new global::Envoy.Api.V3Alpha.Core.GrpcService(); } GrpcService.MergeFrom(other.GrpcService); } if (other.FailureModeAllow != false) { FailureModeAllow = other.FailureModeAllow; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public async Task GrpcService_A_Test() { var locator = new GrpcLocator { NoCache = true, Randomize = true }; Console.WriteLine("Testing in {0}", locator.ServiceDomain); GrpcService svc = await locator.Locate("onumbers", ChannelCredentials.Insecure); Assert.IsNotNull(svc); Assert.IsTrue(svc.Endpoints.Count > 0); // for testing - remove servers 4/5 //svc.Endpoints.Remove(svc.Endpoints.First(ep => ep.Host == "vsrcoredock04.ipzhost.net")); //svc.Endpoints.Remove(svc.Endpoints.First(ep => ep.Host == "vsrcoredock05.ipzhost.net")); foreach (GrpcEndpoint ep in svc.Endpoints) { Console.WriteLine(ep); } Assert.IsTrue(svc.Expires < DateTime.UtcNow.AddMinutes(15)); Console.WriteLine(); int ts = Environment.TickCount; //TimeSpan tryNextAfter = Timeout.InfiniteTimeSpan; TimeSpan tryNextAfter = TimeSpan.FromMilliseconds(150); var channel = svc.Connect(TimeSpan.FromSeconds(3), tryNextAfter).Result; Assert.IsTrue(channel.State == ChannelState.Ready); Console.WriteLine("Connected To: '{0}' in {1}ms", channel.Target, Environment.TickCount - ts); }
public void Execute(GrpcService grpcService) { Console.WriteLine($"Waiting for {_waitTime} milliseconds"); Thread.Sleep(_waitTime); }
public void Execute(GrpcService grpcService) { Console.WriteLine($"Client executing write command with {_partitionId} {_objectId} {_objectValue}"); grpcService.Write(_partitionId, _objectId, _objectValue); }
public GrpcModel(ConsulService consulSrv, GrpcService grpcSrv) { _consulSrv = consulSrv; _grpcSrv = grpcSrv; }
public ClusterVNode(TFChunkDb db, ClusterVNodeSettings vNodeSettings, IGossipSeedSource gossipSeedSource, InfoController infoController, params ISubsystem[] subsystems) { Ensure.NotNull(db, "db"); Ensure.NotNull(vNodeSettings, "vNodeSettings"); Ensure.NotNull(gossipSeedSource, "gossipSeedSource"); #if DEBUG AddTask(_taskAddedTrigger.Task); #endif var isSingleNode = vNodeSettings.ClusterNodeCount == 1; _nodeInfo = vNodeSettings.NodeInfo; _mainBus = new InMemoryBus("MainBus"); var forwardingProxy = new MessageForwardingProxy(); if (vNodeSettings.EnableHistograms) { HistogramService.CreateHistograms(); //start watching jitter HistogramService.StartJitterMonitor(); } // MISC WORKERS _workerBuses = Enumerable.Range(0, vNodeSettings.WorkerThreads).Select(queueNum => new InMemoryBus(string.Format("Worker #{0} Bus", queueNum + 1), watchSlowMsg: true, slowMsgThreshold: TimeSpan.FromMilliseconds(200))).ToArray(); _workersHandler = new MultiQueuedHandler( vNodeSettings.WorkerThreads, queueNum => new QueuedHandlerThreadPool(_workerBuses[queueNum], string.Format("Worker #{0}", queueNum + 1), groupName: "Workers", watchSlowMsg: true, slowMsgThreshold: TimeSpan.FromMilliseconds(200))); _subsystems = subsystems; _controller = new ClusterVNodeController((IPublisher)_mainBus, _nodeInfo, db, vNodeSettings, this, forwardingProxy, _subsystems); _mainQueue = QueuedHandler.CreateQueuedHandler(_controller, "MainQueue"); _controller.SetMainQueue(_mainQueue); //SELF _mainBus.Subscribe <SystemMessage.StateChangeMessage>(this); _mainBus.Subscribe <SystemMessage.BecomeShutdown>(this); // MONITORING var monitoringInnerBus = new InMemoryBus("MonitoringInnerBus", watchSlowMsg: false); var monitoringRequestBus = new InMemoryBus("MonitoringRequestBus", watchSlowMsg: false); var monitoringQueue = new QueuedHandlerThreadPool(monitoringInnerBus, "MonitoringQueue", true, TimeSpan.FromMilliseconds(800)); var monitoring = new MonitoringService(monitoringQueue, monitoringRequestBus, _mainQueue, db.Config.WriterCheckpoint, db.Config.Path, vNodeSettings.StatsPeriod, _nodeInfo.ExternalHttp, vNodeSettings.StatsStorage, _nodeInfo.ExternalTcp, _nodeInfo.ExternalSecureTcp); _mainBus.Subscribe(monitoringQueue.WidenFrom <SystemMessage.SystemInit, Message>()); _mainBus.Subscribe(monitoringQueue.WidenFrom <SystemMessage.StateChangeMessage, Message>()); _mainBus.Subscribe(monitoringQueue.WidenFrom <SystemMessage.BecomeShuttingDown, Message>()); _mainBus.Subscribe(monitoringQueue.WidenFrom <SystemMessage.BecomeShutdown, Message>()); _mainBus.Subscribe(monitoringQueue.WidenFrom <ClientMessage.WriteEventsCompleted, Message>()); monitoringInnerBus.Subscribe <SystemMessage.SystemInit>(monitoring); monitoringInnerBus.Subscribe <SystemMessage.StateChangeMessage>(monitoring); monitoringInnerBus.Subscribe <SystemMessage.BecomeShuttingDown>(monitoring); monitoringInnerBus.Subscribe <SystemMessage.BecomeShutdown>(monitoring); monitoringInnerBus.Subscribe <ClientMessage.WriteEventsCompleted>(monitoring); monitoringInnerBus.Subscribe <MonitoringMessage.GetFreshStats>(monitoring); monitoringInnerBus.Subscribe <MonitoringMessage.GetFreshTcpConnectionStats>(monitoring); var truncPos = db.Config.TruncateCheckpoint.Read(); var writerCheckpoint = db.Config.WriterCheckpoint.Read(); var chaserCheckpoint = db.Config.ChaserCheckpoint.Read(); var epochCheckpoint = db.Config.EpochCheckpoint.Read(); if (truncPos != -1) { Log.Info( "Truncate checkpoint is present. Truncate: {truncatePosition} (0x{truncatePosition:X}), Writer: {writerCheckpoint} (0x{writerCheckpoint:X}), Chaser: {chaserCheckpoint} (0x{chaserCheckpoint:X}), Epoch: {epochCheckpoint} (0x{epochCheckpoint:X})", truncPos, truncPos, writerCheckpoint, writerCheckpoint, chaserCheckpoint, chaserCheckpoint, epochCheckpoint, epochCheckpoint); var truncator = new TFChunkDbTruncator(db.Config); truncator.TruncateDb(truncPos); } // STORAGE SUBSYSTEM db.Open(vNodeSettings.VerifyDbHash, threads: vNodeSettings.InitializationThreads); var indexPath = vNodeSettings.Index ?? Path.Combine(db.Config.Path, "index"); var maxReaderCount = ESConsts.PTableMaxReaderCount + vNodeSettings.ReaderThreadsCount; var readerPool = new ObjectPool <ITransactionFileReader>( "ReadIndex readers pool", ESConsts.PTableInitialReaderCount, maxReaderCount, () => new TFChunkReader(db, db.Config.WriterCheckpoint, optimizeReadSideCache: db.Config.OptimizeReadSideCache)); var tableIndex = new TableIndex(indexPath, new XXHashUnsafe(), new Murmur3AUnsafe(), () => new HashListMemTable(vNodeSettings.IndexBitnessVersion, maxSize: vNodeSettings.MaxMemtableEntryCount * 2), () => new TFReaderLease(readerPool), vNodeSettings.IndexBitnessVersion, maxSizeForMemory: vNodeSettings.MaxMemtableEntryCount, maxTablesPerLevel: 2, inMem: db.Config.InMemDb, skipIndexVerify: vNodeSettings.SkipIndexVerify, indexCacheDepth: vNodeSettings.IndexCacheDepth, initializationThreads: vNodeSettings.InitializationThreads, additionalReclaim: false, maxAutoMergeIndexLevel: vNodeSettings.MaxAutoMergeIndexLevel); var readIndex = new ReadIndex(_mainQueue, readerPool, tableIndex, ESConsts.StreamInfoCacheCapacity, Application.IsDefined(Application.AdditionalCommitChecks), Application.IsDefined(Application.InfiniteMetastreams) ? int.MaxValue : 1, vNodeSettings.HashCollisionReadLimit, vNodeSettings.SkipIndexScanOnReads, db.Config.ReplicationCheckpoint); var writer = new TFChunkWriter(db); var epochManager = new EpochManager(_mainQueue, ESConsts.CachedEpochCount, db.Config.EpochCheckpoint, writer, initialReaderCount: 1, maxReaderCount: 5, readerFactory: () => new TFChunkReader(db, db.Config.WriterCheckpoint, optimizeReadSideCache: db.Config.OptimizeReadSideCache)); epochManager.Init(); var storageWriter = new ClusterStorageWriterService(_mainQueue, _mainBus, vNodeSettings.MinFlushDelay, db, writer, readIndex.IndexWriter, epochManager, () => readIndex.LastCommitPosition); // subscribes internally AddTasks(storageWriter.Tasks); monitoringRequestBus.Subscribe <MonitoringMessage.InternalStatsRequest>(storageWriter); var storageReader = new StorageReaderService(_mainQueue, _mainBus, readIndex, vNodeSettings.ReaderThreadsCount, db.Config.WriterCheckpoint); _mainBus.Subscribe <SystemMessage.SystemInit>(storageReader); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(storageReader); _mainBus.Subscribe <SystemMessage.BecomeShutdown>(storageReader); monitoringRequestBus.Subscribe <MonitoringMessage.InternalStatsRequest>(storageReader); var indexCommitterService = new IndexCommitterService(readIndex.IndexCommitter, _mainQueue, db.Config.ReplicationCheckpoint, db.Config.WriterCheckpoint, vNodeSettings.CommitAckCount, tableIndex); AddTask(indexCommitterService.Task); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(indexCommitterService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(indexCommitterService); _mainBus.Subscribe <StorageMessage.CommitAck>(indexCommitterService); _mainBus.Subscribe <ClientMessage.MergeIndexes>(indexCommitterService); var chaser = new TFChunkChaser(db, db.Config.WriterCheckpoint, db.Config.ChaserCheckpoint, db.Config.OptimizeReadSideCache); var storageChaser = new StorageChaser(_mainQueue, db.Config.WriterCheckpoint, chaser, indexCommitterService, epochManager); AddTask(storageChaser.Task); #if DEBUG QueueStatsCollector.InitializeCheckpoints( _nodeInfo.DebugIndex, db.Config.WriterCheckpoint, db.Config.ChaserCheckpoint); #endif _mainBus.Subscribe <SystemMessage.SystemInit>(storageChaser); _mainBus.Subscribe <SystemMessage.SystemStart>(storageChaser); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(storageChaser); // AUTHENTICATION INFRASTRUCTURE - delegate to plugins _internalAuthenticationProvider = vNodeSettings.AuthenticationProviderFactory.BuildAuthenticationProvider(_mainQueue, _mainBus, _workersHandler, _workerBuses); Ensure.NotNull(_internalAuthenticationProvider, "authenticationProvider"); { // gRpc service for Rx var gRpcService = new GrpcService(_mainQueue, host: "127.0.0.1", port: 5001); _mainBus.Subscribe <SystemMessage.SystemInit>(gRpcService); _mainBus.Subscribe <SystemMessage.SystemStart>(gRpcService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(gRpcService); } { // EXTERNAL TCP if (!vNodeSettings.DisableInsecureTCP) { var extTcpService = new TcpService(_mainQueue, _nodeInfo.ExternalTcp, _workersHandler, TcpServiceType.External, TcpSecurityType.Normal, new ClientTcpDispatcher(), vNodeSettings.ExtTcpHeartbeatInterval, vNodeSettings.ExtTcpHeartbeatTimeout, _internalAuthenticationProvider, null, vNodeSettings.ConnectionPendingSendBytesThreshold); _mainBus.Subscribe <SystemMessage.SystemInit>(extTcpService); _mainBus.Subscribe <SystemMessage.SystemStart>(extTcpService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(extTcpService); } // EXTERNAL SECURE TCP if (_nodeInfo.ExternalSecureTcp != null) { var extSecTcpService = new TcpService(_mainQueue, _nodeInfo.ExternalSecureTcp, _workersHandler, TcpServiceType.External, TcpSecurityType.Secure, new ClientTcpDispatcher(), vNodeSettings.ExtTcpHeartbeatInterval, vNodeSettings.ExtTcpHeartbeatTimeout, _internalAuthenticationProvider, vNodeSettings.Certificate, vNodeSettings.ConnectionPendingSendBytesThreshold); _mainBus.Subscribe <SystemMessage.SystemInit>(extSecTcpService); _mainBus.Subscribe <SystemMessage.SystemStart>(extSecTcpService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(extSecTcpService); } if (!isSingleNode) { // INTERNAL TCP if (!vNodeSettings.DisableInsecureTCP) { var intTcpService = new TcpService(_mainQueue, _nodeInfo.InternalTcp, _workersHandler, TcpServiceType.Internal, TcpSecurityType.Normal, new InternalTcpDispatcher(), vNodeSettings.IntTcpHeartbeatInterval, vNodeSettings.IntTcpHeartbeatTimeout, _internalAuthenticationProvider, null, ESConsts.UnrestrictedPendingSendBytes); _mainBus.Subscribe <SystemMessage.SystemInit>(intTcpService); _mainBus.Subscribe <SystemMessage.SystemStart>(intTcpService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(intTcpService); } // INTERNAL SECURE TCP if (_nodeInfo.InternalSecureTcp != null) { var intSecTcpService = new TcpService(_mainQueue, _nodeInfo.InternalSecureTcp, _workersHandler, TcpServiceType.Internal, TcpSecurityType.Secure, new InternalTcpDispatcher(), vNodeSettings.IntTcpHeartbeatInterval, vNodeSettings.IntTcpHeartbeatTimeout, _internalAuthenticationProvider, vNodeSettings.Certificate, ESConsts.UnrestrictedPendingSendBytes); _mainBus.Subscribe <SystemMessage.SystemInit>(intSecTcpService); _mainBus.Subscribe <SystemMessage.SystemStart>(intSecTcpService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(intSecTcpService); } } } SubscribeWorkers(bus => { var tcpSendService = new TcpSendService(); // ReSharper disable RedundantTypeArgumentsOfMethod bus.Subscribe <TcpMessage.TcpSend>(tcpSendService); // ReSharper restore RedundantTypeArgumentsOfMethod }); var httpAuthenticationProviders = new List <HttpAuthenticationProvider> { new BasicHttpAuthenticationProvider(_internalAuthenticationProvider), }; if (vNodeSettings.EnableTrustedAuth) { httpAuthenticationProviders.Add(new TrustedHttpAuthenticationProvider()); } httpAuthenticationProviders.Add(new AnonymousHttpAuthenticationProvider()); var httpPipe = new HttpMessagePipe(); var httpSendService = new HttpSendService(httpPipe, forwardRequests: true); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(httpSendService); _mainBus.Subscribe(new WideningHandler <HttpMessage.SendOverHttp, Message>(_workersHandler)); SubscribeWorkers(bus => { bus.Subscribe <HttpMessage.HttpSend>(httpSendService); bus.Subscribe <HttpMessage.HttpSendPart>(httpSendService); bus.Subscribe <HttpMessage.HttpBeginSend>(httpSendService); bus.Subscribe <HttpMessage.HttpEndSend>(httpSendService); bus.Subscribe <HttpMessage.SendOverHttp>(httpSendService); }); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(infoController); var adminController = new AdminController(_mainQueue, _workersHandler); var pingController = new PingController(); var histogramController = new HistogramController(); var statController = new StatController(monitoringQueue, _workersHandler); var atomController = new AtomController(httpSendService, _mainQueue, _workersHandler, vNodeSettings.DisableHTTPCaching); var gossipController = new GossipController(_mainQueue, _workersHandler, vNodeSettings.GossipTimeout); var persistentSubscriptionController = new PersistentSubscriptionController(httpSendService, _mainQueue, _workersHandler); var electController = new ElectController(_mainQueue); // HTTP SENDERS gossipController.SubscribeSenders(httpPipe); electController.SubscribeSenders(httpPipe); // EXTERNAL HTTP _externalHttpService = new HttpService(ServiceAccessibility.Public, _mainQueue, new TrieUriRouter(), _workersHandler, vNodeSettings.LogHttpRequests, vNodeSettings.GossipAdvertiseInfo.AdvertiseExternalIPAs, vNodeSettings.GossipAdvertiseInfo.AdvertiseExternalHttpPortAs, vNodeSettings.DisableFirstLevelHttpAuthorization, vNodeSettings.ExtHttpPrefixes); _externalHttpService.SetupController(persistentSubscriptionController); if (vNodeSettings.AdminOnPublic) { _externalHttpService.SetupController(adminController); } _externalHttpService.SetupController(pingController); _externalHttpService.SetupController(infoController); if (vNodeSettings.StatsOnPublic) { _externalHttpService.SetupController(statController); } _externalHttpService.SetupController(atomController); if (vNodeSettings.GossipOnPublic) { _externalHttpService.SetupController(gossipController); } _externalHttpService.SetupController(histogramController); _mainBus.Subscribe <SystemMessage.SystemInit>(_externalHttpService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(_externalHttpService); _mainBus.Subscribe <HttpMessage.PurgeTimedOutRequests>(_externalHttpService); // INTERNAL HTTP if (!isSingleNode) { _internalHttpService = new HttpService(ServiceAccessibility.Private, _mainQueue, new TrieUriRouter(), _workersHandler, vNodeSettings.LogHttpRequests, vNodeSettings.GossipAdvertiseInfo.AdvertiseInternalIPAs, vNodeSettings.GossipAdvertiseInfo.AdvertiseInternalHttpPortAs, vNodeSettings.DisableFirstLevelHttpAuthorization, vNodeSettings.IntHttpPrefixes); _internalHttpService.SetupController(adminController); _internalHttpService.SetupController(pingController); _internalHttpService.SetupController(infoController); _internalHttpService.SetupController(statController); _internalHttpService.SetupController(atomController); _internalHttpService.SetupController(gossipController); _internalHttpService.SetupController(electController); _internalHttpService.SetupController(histogramController); _internalHttpService.SetupController(persistentSubscriptionController); } // Authentication plugin HTTP vNodeSettings.AuthenticationProviderFactory.RegisterHttpControllers(_externalHttpService, _internalHttpService, httpSendService, _mainQueue, _workersHandler); if (_internalHttpService != null) { _mainBus.Subscribe <SystemMessage.SystemInit>(_internalHttpService); _mainBus.Subscribe <SystemMessage.BecomeShuttingDown>(_internalHttpService); _mainBus.Subscribe <HttpMessage.PurgeTimedOutRequests>(_internalHttpService); } SubscribeWorkers(bus => { HttpService.CreateAndSubscribePipeline(bus, httpAuthenticationProviders.ToArray()); }); // REQUEST FORWARDING var forwardingService = new RequestForwardingService(_mainQueue, forwardingProxy, TimeSpan.FromSeconds(1)); _mainBus.Subscribe <SystemMessage.SystemStart>(forwardingService); _mainBus.Subscribe <SystemMessage.RequestForwardingTimerTick>(forwardingService); _mainBus.Subscribe <ClientMessage.NotHandled>(forwardingService); _mainBus.Subscribe <ClientMessage.WriteEventsCompleted>(forwardingService); _mainBus.Subscribe <ClientMessage.TransactionStartCompleted>(forwardingService); _mainBus.Subscribe <ClientMessage.TransactionWriteCompleted>(forwardingService); _mainBus.Subscribe <ClientMessage.TransactionCommitCompleted>(forwardingService); _mainBus.Subscribe <ClientMessage.DeleteStreamCompleted>(forwardingService); // REQUEST MANAGEMENT var requestManagement = new RequestManagementService(_mainQueue, vNodeSettings.PrepareAckCount, vNodeSettings.PrepareTimeout, vNodeSettings.CommitTimeout, vNodeSettings.BetterOrdering); _mainBus.Subscribe <SystemMessage.SystemInit>(requestManagement); _mainBus.Subscribe <ClientMessage.WriteEvents>(requestManagement); _mainBus.Subscribe <ClientMessage.TransactionStart>(requestManagement); _mainBus.Subscribe <ClientMessage.TransactionWrite>(requestManagement); _mainBus.Subscribe <ClientMessage.TransactionCommit>(requestManagement); _mainBus.Subscribe <ClientMessage.DeleteStream>(requestManagement); _mainBus.Subscribe <StorageMessage.RequestCompleted>(requestManagement); _mainBus.Subscribe <StorageMessage.CheckStreamAccessCompleted>(requestManagement); _mainBus.Subscribe <StorageMessage.AlreadyCommitted>(requestManagement); _mainBus.Subscribe <StorageMessage.CommitReplicated>(requestManagement); _mainBus.Subscribe <StorageMessage.PrepareAck>(requestManagement); _mainBus.Subscribe <StorageMessage.WrongExpectedVersion>(requestManagement); _mainBus.Subscribe <StorageMessage.InvalidTransaction>(requestManagement); _mainBus.Subscribe <StorageMessage.StreamDeleted>(requestManagement); _mainBus.Subscribe <StorageMessage.RequestManagerTimerTick>(requestManagement); // SUBSCRIPTIONS var subscrBus = new InMemoryBus("SubscriptionsBus", true, TimeSpan.FromMilliseconds(50)); var subscrQueue = new QueuedHandlerThreadPool(subscrBus, "Subscriptions", false); _mainBus.Subscribe(subscrQueue.WidenFrom <SystemMessage.SystemStart, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <SystemMessage.BecomeShuttingDown, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <TcpMessage.ConnectionClosed, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <ClientMessage.SubscribeToStream, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <ClientMessage.UnsubscribeFromStream, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <SubscriptionMessage.PollStream, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <SubscriptionMessage.CheckPollTimeout, Message>()); _mainBus.Subscribe(subscrQueue.WidenFrom <StorageMessage.EventCommitted, Message>()); var subscription = new SubscriptionsService(_mainQueue, subscrQueue, readIndex); subscrBus.Subscribe <SystemMessage.SystemStart>(subscription); subscrBus.Subscribe <SystemMessage.BecomeShuttingDown>(subscription); subscrBus.Subscribe <TcpMessage.ConnectionClosed>(subscription); subscrBus.Subscribe <ClientMessage.SubscribeToStream>(subscription); subscrBus.Subscribe <ClientMessage.UnsubscribeFromStream>(subscription); subscrBus.Subscribe <SubscriptionMessage.PollStream>(subscription); subscrBus.Subscribe <SubscriptionMessage.CheckPollTimeout>(subscription); subscrBus.Subscribe <StorageMessage.EventCommitted>(subscription); // PERSISTENT SUBSCRIPTIONS // IO DISPATCHER var ioDispatcher = new IODispatcher(_mainQueue, new PublishEnvelope(_mainQueue)); _mainBus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(ioDispatcher.BackwardReader); _mainBus.Subscribe <ClientMessage.WriteEventsCompleted>(ioDispatcher.Writer); _mainBus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(ioDispatcher.ForwardReader); _mainBus.Subscribe <ClientMessage.DeleteStreamCompleted>(ioDispatcher.StreamDeleter); _mainBus.Subscribe(ioDispatcher); var perSubscrBus = new InMemoryBus("PersistentSubscriptionsBus", true, TimeSpan.FromMilliseconds(50)); var perSubscrQueue = new QueuedHandlerThreadPool(perSubscrBus, "PersistentSubscriptions", false); _mainBus.Subscribe(perSubscrQueue.WidenFrom <SystemMessage.StateChangeMessage, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <TcpMessage.ConnectionClosed, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.CreatePersistentSubscription, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.UpdatePersistentSubscription, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.DeletePersistentSubscription, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.ConnectToPersistentSubscription, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.UnsubscribeFromStream, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.PersistentSubscriptionAckEvents, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.PersistentSubscriptionNackEvents, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.ReplayAllParkedMessages, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.ReplayParkedMessage, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <ClientMessage.ReadNextNPersistentMessages, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <StorageMessage.EventCommitted, Message>()); _mainBus.Subscribe(perSubscrQueue .WidenFrom <MonitoringMessage.GetAllPersistentSubscriptionStats, Message>()); _mainBus.Subscribe( perSubscrQueue.WidenFrom <MonitoringMessage.GetStreamPersistentSubscriptionStats, Message>()); _mainBus.Subscribe(perSubscrQueue.WidenFrom <MonitoringMessage.GetPersistentSubscriptionStats, Message>()); _mainBus.Subscribe(perSubscrQueue .WidenFrom <SubscriptionMessage.PersistentSubscriptionTimerTick, Message>()); //TODO CC can have multiple threads working on subscription if partition var consumerStrategyRegistry = new PersistentSubscriptionConsumerStrategyRegistry(_mainQueue, _mainBus, vNodeSettings.AdditionalConsumerStrategies); var persistentSubscription = new PersistentSubscriptionService(perSubscrQueue, readIndex, ioDispatcher, _mainQueue, consumerStrategyRegistry); perSubscrBus.Subscribe <SystemMessage.BecomeShuttingDown>(persistentSubscription); perSubscrBus.Subscribe <SystemMessage.BecomeMaster>(persistentSubscription); perSubscrBus.Subscribe <SystemMessage.StateChangeMessage>(persistentSubscription); perSubscrBus.Subscribe <TcpMessage.ConnectionClosed>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.ConnectToPersistentSubscription>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.UnsubscribeFromStream>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.PersistentSubscriptionAckEvents>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.PersistentSubscriptionNackEvents>(persistentSubscription); perSubscrBus.Subscribe <StorageMessage.EventCommitted>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.DeletePersistentSubscription>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.CreatePersistentSubscription>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.UpdatePersistentSubscription>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.ReplayAllParkedMessages>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.ReplayParkedMessage>(persistentSubscription); perSubscrBus.Subscribe <ClientMessage.ReadNextNPersistentMessages>(persistentSubscription); perSubscrBus.Subscribe <MonitoringMessage.GetAllPersistentSubscriptionStats>(persistentSubscription); perSubscrBus.Subscribe <MonitoringMessage.GetStreamPersistentSubscriptionStats>(persistentSubscription); perSubscrBus.Subscribe <MonitoringMessage.GetPersistentSubscriptionStats>(persistentSubscription); perSubscrBus.Subscribe <SubscriptionMessage.PersistentSubscriptionTimerTick>(persistentSubscription); // STORAGE SCAVENGER var scavengerLogManager = new TFChunkScavengerLogManager(_nodeInfo.ExternalHttp.ToString(), TimeSpan.FromDays(vNodeSettings.ScavengeHistoryMaxAge), ioDispatcher); var storageScavenger = new StorageScavenger(db, tableIndex, readIndex, scavengerLogManager, vNodeSettings.AlwaysKeepScavenged, !vNodeSettings.DisableScavengeMerging, unsafeIgnoreHardDeletes: vNodeSettings.UnsafeIgnoreHardDeletes); // ReSharper disable RedundantTypeArgumentsOfMethod _mainBus.Subscribe <ClientMessage.ScavengeDatabase>(storageScavenger); _mainBus.Subscribe <ClientMessage.StopDatabaseScavenge>(storageScavenger); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(storageScavenger); // ReSharper restore RedundantTypeArgumentsOfMethod // TIMER _timeProvider = new RealTimeProvider(); var threadBasedScheduler = new ThreadBasedScheduler(_timeProvider); AddTask(threadBasedScheduler.Task); _timerService = new TimerService(threadBasedScheduler); _mainBus.Subscribe <SystemMessage.BecomeShutdown>(_timerService); _mainBus.Subscribe <TimerMessage.Schedule>(_timerService); var gossipInfo = new VNodeInfo(_nodeInfo.InstanceId, _nodeInfo.DebugIndex, vNodeSettings.GossipAdvertiseInfo.InternalTcp, vNodeSettings.GossipAdvertiseInfo.InternalSecureTcp, vNodeSettings.GossipAdvertiseInfo.ExternalTcp, vNodeSettings.GossipAdvertiseInfo.ExternalSecureTcp, vNodeSettings.GossipAdvertiseInfo.InternalHttp, vNodeSettings.GossipAdvertiseInfo.ExternalHttp); if (!isSingleNode) { // MASTER REPLICATION var masterReplicationService = new MasterReplicationService(_mainQueue, gossipInfo.InstanceId, db, _workersHandler, epochManager, vNodeSettings.ClusterNodeCount); AddTask(masterReplicationService.Task); _mainBus.Subscribe <SystemMessage.SystemStart>(masterReplicationService); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(masterReplicationService); _mainBus.Subscribe <ReplicationMessage.ReplicaSubscriptionRequest>(masterReplicationService); _mainBus.Subscribe <ReplicationMessage.ReplicaLogPositionAck>(masterReplicationService); monitoringInnerBus.Subscribe <ReplicationMessage.GetReplicationStats>(masterReplicationService); // REPLICA REPLICATION var replicaService = new ReplicaService(_mainQueue, db, epochManager, _workersHandler, _internalAuthenticationProvider, gossipInfo, vNodeSettings.UseSsl, vNodeSettings.SslTargetHost, vNodeSettings.SslValidateServer, vNodeSettings.IntTcpHeartbeatTimeout, vNodeSettings.ExtTcpHeartbeatInterval); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(replicaService); _mainBus.Subscribe <ReplicationMessage.ReconnectToMaster>(replicaService); _mainBus.Subscribe <ReplicationMessage.SubscribeToMaster>(replicaService); _mainBus.Subscribe <ReplicationMessage.AckLogPosition>(replicaService); _mainBus.Subscribe <StorageMessage.PrepareAck>(replicaService); _mainBus.Subscribe <StorageMessage.CommitAck>(replicaService); _mainBus.Subscribe <ClientMessage.TcpForwardMessage>(replicaService); } // ELECTIONS var electionsService = new ElectionsService(_mainQueue, gossipInfo, vNodeSettings.ClusterNodeCount, db.Config.WriterCheckpoint, db.Config.ChaserCheckpoint, epochManager, () => readIndex.LastCommitPosition, vNodeSettings.NodePriority); electionsService.SubscribeMessages(_mainBus); if (!isSingleNode || vNodeSettings.GossipOnSingleNode) { // GOSSIP var gossip = new NodeGossipService(_mainQueue, gossipSeedSource, gossipInfo, db.Config.WriterCheckpoint, db.Config.ChaserCheckpoint, epochManager, () => readIndex.LastCommitPosition, vNodeSettings.NodePriority, vNodeSettings.GossipInterval, vNodeSettings.GossipAllowedTimeDifference); _mainBus.Subscribe <SystemMessage.SystemInit>(gossip); _mainBus.Subscribe <GossipMessage.RetrieveGossipSeedSources>(gossip); _mainBus.Subscribe <GossipMessage.GotGossipSeedSources>(gossip); _mainBus.Subscribe <GossipMessage.Gossip>(gossip); _mainBus.Subscribe <GossipMessage.GossipReceived>(gossip); _mainBus.Subscribe <SystemMessage.StateChangeMessage>(gossip); _mainBus.Subscribe <GossipMessage.GossipSendFailed>(gossip); _mainBus.Subscribe <SystemMessage.VNodeConnectionEstablished>(gossip); _mainBus.Subscribe <SystemMessage.VNodeConnectionLost>(gossip); } AddTasks(_workersHandler.Start()); AddTask(_mainQueue.Start()); AddTask(monitoringQueue.Start()); AddTask(subscrQueue.Start()); AddTask(perSubscrQueue.Start()); if (subsystems != null) { foreach (var subsystem in subsystems) { var http = isSingleNode ? new[] { _externalHttpService } : new[] { _internalHttpService, _externalHttpService }; subsystem.Register(new StandardComponents(db, _mainQueue, _mainBus, _timerService, _timeProvider, httpSendService, http, _workersHandler)); } } }
public void Execute(GrpcService grpcService) { var response = grpcService.Read(_partitionId, _objectId, _serverId); Console.WriteLine($"Read from partition {_partitionId} object {_objectId} returned {response}"); }
protected async Task StartRunners(IConfigProvider configProvider) { var initParams = configProvider.GetConfig <IInitConfig>(); var metricsParams = configProvider.GetConfig <IMetricsConfig>(); var logManager = new NLogManager(initParams.LogFileName, initParams.LogDirectory); IRpcModuleProvider rpcModuleProvider = initParams.JsonRpcEnabled ? new RpcModuleProvider(configProvider.GetConfig <IJsonRpcConfig>()) : (IRpcModuleProvider)NullModuleProvider.Instance; var webSocketsManager = new WebSocketsManager(); INdmDataPublisher ndmDataPublisher = null; INdmConsumerChannelManager ndmConsumerChannelManager = null; INdmInitializer ndmInitializer = null; var ndmConfig = configProvider.GetConfig <INdmConfig>(); var ndmEnabled = ndmConfig.Enabled; if (ndmEnabled) { ndmDataPublisher = new NdmDataPublisher(); ndmConsumerChannelManager = new NdmConsumerChannelManager(); ndmInitializer = new NdmInitializerFactory(logManager) .CreateOrFail(ndmConfig.InitializerName, ndmConfig.PluginsPath); } var grpcConfig = configProvider.GetConfig <IGrpcConfig>(); GrpcService grpcService = null; if (grpcConfig.Enabled) { grpcService = new GrpcService(logManager); if (ndmEnabled) { ndmConsumerChannelManager.Add(new GrpcNdmConsumerChannel(grpcService)); } _grpcRunner = new GrpcRunner(grpcService, grpcConfig, logManager); await _grpcRunner.Start().ContinueWith(x => { if (x.IsFaulted && Logger.IsError) { Logger.Error("Error during GRPC runner start", x.Exception); } }); } GrpcClient grpcClient = null; var grpcClientConfig = configProvider.GetConfig <IGrpcClientConfig>(); if (grpcClientConfig.Enabled) { grpcClient = new GrpcClient(grpcClientConfig, new EthereumJsonSerializer(), logManager); _grpcClientRunner = new GrpcClientRunner(grpcClient, grpcClientConfig, logManager); await Task.Factory.StartNew(() => _grpcClientRunner.Start().ContinueWith(x => { if (x.IsFaulted && Logger.IsError) { Logger.Error("Error during GRPC client runner start", x.Exception); } })); } _ethereumRunner = new EthereumRunner(rpcModuleProvider, configProvider, logManager, grpcService, grpcClient, ndmConsumerChannelManager, ndmDataPublisher, ndmInitializer); await _ethereumRunner.Start().ContinueWith(x => { if (x.IsFaulted && Logger.IsError) { Logger.Error("Error during ethereum runner start", x.Exception); } }); if (initParams.JsonRpcEnabled) { var serializer = new EthereumJsonSerializer(); rpcModuleProvider.Register <IWeb3Module>(new Web3Module(logManager)); var jsonRpcService = new JsonRpcService(rpcModuleProvider, logManager); var jsonRpcProcessor = new JsonRpcProcessor(jsonRpcService, serializer, logManager); webSocketsManager.AddModule(new JsonRpcWebSocketsModule(jsonRpcProcessor, serializer)); if (ndmEnabled) { webSocketsManager.AddModule(new NdmWebSocketsModule(ndmConsumerChannelManager, ndmDataPublisher)); } Bootstrap.Instance.JsonRpcService = jsonRpcService; Bootstrap.Instance.LogManager = logManager; Bootstrap.Instance.JsonSerializer = serializer; _jsonRpcRunner = new JsonRpcRunner(configProvider, rpcModuleProvider, logManager, jsonRpcProcessor, webSocketsManager); await _jsonRpcRunner.Start().ContinueWith(x => { if (x.IsFaulted && Logger.IsError) { Logger.Error("Error during jsonRpc runner start", x.Exception); } }); } else { if (Logger.IsInfo) { Logger.Info("Json RPC is disabled"); } } if (metricsParams.MetricsEnabled) { var intervalSeconds = metricsParams.MetricsIntervalSeconds; _monitoringService = new MonitoringService(new MetricsUpdater(intervalSeconds), metricsParams.MetricsPushGatewayUrl, ClientVersion.Description, metricsParams.NodeName, intervalSeconds, logManager); await _monitoringService.StartAsync().ContinueWith(x => { if (x.IsFaulted && Logger.IsError) { Logger.Error("Error during starting a monitoring.", x.Exception); } }); } else { if (Logger.IsInfo) { Logger.Info("Monitoring is disabled"); } } }
public InvokeModel(GrpcService grpcSrv) { _grpcSrv = grpcSrv; }