/// <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); }
/// <inheritdoc/> public void Perform() { _pullConnectors.Register(); _pushConnectors.Register(); }