public void Start( Action<TTelemetryBatch, ServerCallContext> onBatchReceived, Func<CurrentLibraryConfig, ServerCallContext, UpdatedLibraryConfig> onConfigReceived) { if (this.IsRunning) { throw new InvalidOperationException( FormattableString.Invariant($"Can't Start the input, it's already running")); } this.stats = new InputStats(); this.cts = new CancellationTokenSource(); this.onBatchReceived = onBatchReceived; this.onConfigReceived = onConfigReceived; try { this.server = new Server { Services = {this.aiServer != null ? AITelemetryService.BindService(this.aiServer) : TraceService.BindService(this.openCensusServer)}, Ports = {new ServerPort(this.host, this.port, ServerCredentials.Insecure)} }; this.server.Start(); this.IsRunning = true; } catch (System.Exception e) { throw new InvalidOperationException( FormattableString.Invariant($"Could not initialize the gRPC server. {e.ToString()}")); } }