Exemple #1
0
        public void Start(Action <TTelemetryBatch> onBatchReceived)
        {
            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;

            try
            {
                this.server = new Server
                {
                    Services = { this.aiServer != null ? AITelemetryService.BindService(this.aiServer) : Export.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()}"));
            }
        }