/// <summary> /// Constructor /// </summary> public RemoteWorker( bool isGrpcEnabled, LoggingContext appLoggingContext, uint workerId, MasterService masterService, ServiceLocation serviceLocation) : base(workerId, name: I($"#{workerId} ({serviceLocation.IpAddress}::{serviceLocation.Port})")) { m_isGrpcEnabled = isGrpcEnabled; m_appLoggingContext = appLoggingContext; m_masterService = masterService; m_buildRequests = new BlockingCollection <ValueTuple <PipCompletionTask, SinglePipBuildRequest> >(); m_attachCompletion = TaskSourceSlim.Create <bool>(); m_executionBlobCompletion = TaskSourceSlim.Create <bool>(); m_serviceLocation = serviceLocation; if (isGrpcEnabled) { m_workerClient = new Grpc.GrpcWorkerClient(m_appLoggingContext, masterService.DistributionServices.BuildId, serviceLocation.IpAddress, serviceLocation.Port); } else { #if !DISABLE_FEATURE_BOND_RPC m_workerClient = new InternalBond.BondWorkerClient(m_appLoggingContext, Name, serviceLocation.IpAddress, serviceLocation.Port, masterService.DistributionServices, OnActivateConnection, OnDeactivateConnection, OnConnectionTimeOut); #endif } // Depending on how long send requests take. It might make sense to use the same thread between all workers. m_sendThread = new Thread(SendBuildRequests); }
public async Task StartAsync() { Logger.SetLogMe(this); try { if (workerClient != null) { await workerClient.StopAsync(); } appCrash = new AppCrash(); CrashReportWindow.AppCrash = appCrash; CrashReportWindow.OnReport = HandleCrashReport; appCrash.Register(typeof(CrashReportWindow)); appCrash.ProductName = SystemInfo.GetAppName(); var appName = SystemInfo.GetAppName(); var clientId = GetClientId(appName); var mqttIWorkerClient = new MqttIWorkerClient(clientId, url, appName); mqttIWorkerClient.CommandHandler = this; await mqttIWorkerClient.StartAsync(); workerClient = mqttIWorkerClient; } catch (Exception ex) { Logger.E("Error while starting " + GetType().Name, ex); } }
public async Task StopAsync() { Logger.SetLogMe(null); CrashReportWindow.AppCrash = null; CrashReportWindow.OnReport = null; try { var workerClient = this.workerClient; if (workerClient != null) { await workerClient.StopAsync(); this.workerClient = null; } } catch { } }
public void Create(out IWorkerClient @object, IClientLink link) => @object = new WorkerClient(link);