Ejemplo n.º 1
0
        /// <summary>
        ///   Creates an event sender responsible for transmitting <see cref="EventData" /> to the
        ///   Event Hub, grouped together in batches.  Depending on the <paramref name="senderOptions"/>
        ///   specified, the sender may be created to allow event data to be automatically routed to an available
        ///   partition or specific to a partition.
        /// </summary>
        ///
        /// <param name="senderOptions">The set of options to apply when creating the sender.</param>
        ///
        /// <returns>An event sender configured in the requested manner.</returns>
        ///
        /// <remarks>
        ///   Allowing automatic routing of partitions is recommended when:
        ///   <para>- The sending of events needs to be highly available.</para>
        ///   <para>- The event data should be evenly distributed among all available partitions.</para>
        ///
        ///   If no partition is specified, the following rules are used for automatically selecting one:
        ///   <para>1) Distribute the events equally amongst all available partitions using a round-robin approach.</para>
        ///   <para>2) If a partition becomes unavailable, the Event Hubs service will automatically detect it and forward the message to another available partition.</para>
        /// </remarks>
        ///
        public virtual EventSender CreateSender(SenderOptions senderOptions = default)
        {
            //TODO: If no options were reeived, create a new set.  Otherwise, copy them.
            //TODO: If options are missing values that the client should default, set them.

            return(new EventSender(ClientOptions.ConnectionType, EventHubPath, senderOptions));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Creates an event sender responsible for transmitting <see cref="EventData" /> to the
        ///   Event Hub, grouped together in batches.  Depending on the <paramref name="senderOptions"/>
        ///   specified, the sender may be created to allow event data to be automatically routed to an available
        ///   partition or specific to a partition.
        /// </summary>
        ///
        /// <param name="senderOptions">The set of options to apply when creating the sender.</param>
        ///
        /// <returns>An event sender configured in the requested manner.</returns>
        ///
        /// <remarks>
        ///   Allowing automatic routing of partitions is recommended when:
        ///   <para>- The sending of events needs to be highly available.</para>
        ///   <para>- The event data should be evenly distributed among all available partitions.</para>
        ///
        ///   If no partition is specified, the following rules are used for automatically selecting one:
        ///   <para>1) Distribute the events equally amongst all available partitions using a round-robin approach.</para>
        ///   <para>2) If a partition becomes unavailable, the Event Hubs service will automatically detect it and forward the message to another available partition.</para>
        /// </remarks>
        ///
        public virtual EventSender CreateSender(SenderOptions senderOptions = default)
        {
            var options = senderOptions?.Clone() ?? new SenderOptions {
                Retry = null, Timeout = null
            };

            options.Retry   = options.Retry ?? ClientOptions.Retry.Clone();
            options.Timeout = options.TimeoutOrDefault ?? ClientOptions.DefaultTimeout;

            return(BuildEventSender(ClientOptions.ConnectionType, EventHubPath, options));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="EventSender"/> class.
        /// </summary>
        ///
        /// <param name="connectionType">The type of connection used for communicating with the Event Hubs service.</param>
        /// <param name="eventHubPath">The path of the Event Hub to which events will be sent.</param>
        /// <param name="senderOptions">The set of options to use for this receiver.</param>
        ///
        protected internal EventSender(ConnectionType connectionType,
                                       string eventHubPath,
                                       SenderOptions senderOptions)
        {
            Guard.ArgumentNotNullOrEmpty(nameof(eventHubPath), eventHubPath);

            PartitionId = senderOptions?.PartitionId;

            //TODO: Validate and clone the options (to avoid any changes on the options being carried over)
            //TODO: Connection Type drives the contained receiver used for service operations. For example, an AmqpEventSender.
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="EventSender"/> class.
        /// </summary>
        ///
        /// <param name="connectionType">The type of connection used for communicating with the Event Hubs service.</param>
        /// <param name="eventHubPath">The path of the Event Hub to which events will be sent.</param>
        /// <param name="senderOptions">The set of options to use for this receiver.</param>
        ///
        /// <remarks>
        ///   Because this is a non-public constructor, it is assumed that the <paramref name="senderOptions" /> passed are
        ///   owned by this instance and are safe from changes made by consumers.  It is considered the responsibility of the
        ///   caller to ensure that any needed cloning of options is performed.
        /// </remarks>
        ///
        protected internal EventSender(ConnectionType connectionType,
                                       string eventHubPath,
                                       SenderOptions senderOptions)
        {
            Guard.ArgumentNotNullOrEmpty(nameof(eventHubPath), eventHubPath);
            Guard.ArgumentNotNull(nameof(senderOptions), senderOptions);

            PartitionId = senderOptions?.PartitionId;
            Options     = senderOptions;

            //TODO: Connection Type drives the contained receiver used for service operations. For example, an AmqpEventSender.
        }
Ejemplo n.º 5
0
 /// <summary>
 ///   Builds an event sender instance using the provided options.
 /// </summary>
 ///
 /// <param name="connectionType">The type of connection being used for communication with the EventHubs servcie.</param>
 /// <param name="eventHubPath">The path to a specific Event Hub.</param>
 /// <param name="options">The set of options to use for the sender.</param>
 ///
 /// <returns>The fully constructed sender.</returns>
 ///
 protected virtual EventSender BuildEventSender(ConnectionType connectionType,
                                                string eventHubPath,
                                                SenderOptions options) =>
 new EventSender(connectionType, eventHubPath, options);
 /// <summary>
 ///   Builds an event sender instance using the provided options.
 /// </summary>
 ///
 /// <param name="connectionType">The type of connection being used for communication with the EventHubs servcie.</param>
 /// <param name="eventHubPath">The path to a specific Event Hub.</param>
 /// <param name="options">The set of options to use for the sender.</param>
 ///
 /// <returns>The fully constructed sender.</returns>
 ///
 internal virtual EventSender BuildEventSender(TransportType connectionType,
                                               string eventHubPath,
                                               SenderOptions options) =>
 new EventSender(connectionType, eventHubPath, options);