Beispiel #1
0
        /// <inheritdoc/>
        public override Task Connect(grpc.PullConnector request, IServerStreamWriter <grpc.PullRequest> responseStream, ServerCallContext context)
        {
            var id            = request.Id.ToGuid();
            var pullConnector = new PullConnector(id, request.Name, request.Interval);

            ITimer timer = null;

            try
            {
                _pullConnectors.Register(pullConnector);

                timer = _timers.Every(pullConnector.Interval, () =>
                {
                    var pullRequest = new grpc.PullRequest();
                    responseStream.WriteAsync(pullRequest);
                });

                context.CancellationToken.ThrowIfCancellationRequested();
                context.CancellationToken.WaitHandle.WaitOne();
            }
            finally
            {
                timer?.Stop();
                timer?.Dispose();

                _pullConnectors.Unregister(pullConnector);
            }

            return(Task.CompletedTask);
        }
Beispiel #2
0
 /// <inheritdoc/>
 public void Perform()
 {
     _pullConnectors.Register();
     _pushConnectors.Register();
 }