/// <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(); }
/// <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(); }
/// <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)); }
/// <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(); }
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); }
/// <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); }
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)); }
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); }
/// <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); }