コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobStorageTransmitter"/> class.
        /// </summary>
        /// <param name="storage">A transmission storage instance.</param>
        /// <param name="sender">A transmission sender instance.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="storage"/> must not be <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="sender"/> must not be <c>null</c>.
        /// </exception>
        public BlobStorageTransmitter(ITransmissionStorage <AttachmentDescriptor> storage,
                                      ITransmissionSender <AttachmentDescriptor> sender)
        {
            _storage = storage ?? throw new ArgumentNullException(nameof(storage));
            _sender  = sender ?? throw new ArgumentNullException(nameof(sender));

            StartAsyncSending();
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventHubTransmitter"/> class.
        /// </summary>
        /// <param name="buffer">A transmission buffer instance.</param>
        /// <param name="sender">A transmission sender instance.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="buffer"/> must not be <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="sender"/> must not be <c>null</c>.
        /// </exception>
        internal EventHubTransmitter(ITransmissionBuffer <EventData> buffer,
                                     ITransmissionSender <EventData> sender)
        {
            _buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
            _sender = sender ?? throw new ArgumentNullException(nameof(sender));

            StartAsyncSending();
        }
コード例 #3
0
        /// <summary>
        /// Sends a telemetry data batch to a backend service/solution for further processing.
        /// </summary>
        /// <param name="sender">A transmission sender instance.</param>
        /// <param name="batch">A telemetry event batch.</param>
        public static Task SendAsync <TData>(this ITransmissionSender <TData> sender, IEnumerable <TData> batch)
            where TData : class
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            return(sender.SendAsync(batch, CancellationToken.None));
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventHubTransmitter"/> class.
        /// </summary>
        /// <param name="client">A <c>Azure</c> <c>EventHub</c> client instance.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="client"/> must not be <c>null</c>.
        /// </exception>
        public EventHubTransmitter(EventHubClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            _buffer = new EventHubTransmissionBuffer(client);
            _sender = new EventHubTransmissionSender(client);

            StartAsyncSending();
        }
コード例 #5
0
        public void Constructor_SenderNull()
        {
            // assert
            ITransmissionStorage <AttachmentDescriptor> storage = new Mock <ITransmissionStorage <AttachmentDescriptor> >().Object;
            ITransmissionSender <AttachmentDescriptor>  sender  = null;

            // act
            Action verify = () => new BlobStorageTransmitter(storage, sender);

            // arrange
            Assert.Throws <ArgumentNullException>("sender", verify);
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlobStorageTransmitter"/> class.
        /// </summary>
        public BlobStorageTransmitter(
            IMemoryBuffer <AttachmentDescriptor> buffer,
            ITransmissionStorage <AttachmentDescriptor> storage,
            ITransmissionSender <AttachmentDescriptor> sender,
            ILogger <BlobStorageTransmitter> logger)
        {
            _buffer  = buffer ?? throw new ArgumentNullException(nameof(buffer));
            _storage = storage ?? throw new ArgumentNullException(nameof(storage));
            _sender  = sender ?? throw new ArgumentNullException(nameof(sender));

            _storeTask = TaskHelper
                         .StartLongRunning(StoreAsync, _disposeToken.Token);
            _sendTask = TaskHelper
                        .StartLongRunning(SendAsync, _disposeToken.Token);
        }
コード例 #7
0
        public void Constructor_NoException()
        {
            // assert
            IMemoryBuffer <EventData> buffer = Mock.Of <IMemoryBuffer <EventData> >();
            ITransmissionBuffer <EventData, EventDataBatch> aggregator = Mock.Of <ITransmissionBuffer <EventData, EventDataBatch> >();
            ITransmissionSender <EventDataBatch>            sender     = Mock.Of <ITransmissionSender <EventDataBatch> >();
            ITransmissionStorage <EventData> storage = Mock.Of <ITransmissionStorage <EventData> >();

            // act
            Action verify = () => new EventHubTransmitter(
                buffer, aggregator, sender, storage);

            // arrange
            Assert.Null(Record.Exception(verify));
        }
コード例 #8
0
        public void Constructor_StorageNull()
        {
            // assert
            IMemoryBuffer <EventData> buffer = Mock.Of <IMemoryBuffer <EventData> >();
            ITransmissionBuffer <EventData, EventDataBatch> aggregator = Mock.Of <ITransmissionBuffer <EventData, EventDataBatch> >();
            ITransmissionSender <EventDataBatch>            sender     = Mock.Of <ITransmissionSender <EventDataBatch> >();
            ITransmissionStorage <EventData> storage = null;

            // act
            Action verify = () => new EventHubTransmitter(
                buffer, aggregator, sender, storage);

            // arrange
            Assert.Throws <ArgumentNullException>("storage", verify);
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EventHubTransmitter"/> class.
        /// </summary>
        public EventHubTransmitter(
            IMemoryBuffer <EventData> buffer,
            ITransmissionBuffer <EventData, EventDataBatch> aggregator,
            ITransmissionSender <EventDataBatch> sender,
            ITransmissionStorage <EventData> storage)
        {
            _buffer     = buffer ?? throw new ArgumentNullException(nameof(buffer));
            _aggregator = aggregator ?? throw new ArgumentNullException(nameof(aggregator));
            _sender     = sender ?? throw new ArgumentNullException(nameof(sender));
            _storage    = storage ?? throw new ArgumentNullException(nameof(storage));

            _storeTask = TaskHelper
                         .StartLongRunning(StoreAsync, _disposeToken.Token);
            _aggregateTask = TaskHelper
                             .StartLongRunning(AggregateAsync, _disposeToken.Token);
            _sendTask = TaskHelper
                        .StartLongRunning(SendAsync, _disposeToken.Token);
        }