/// <summary> /// Initializes a new instance of the <see cref="CheckpointManager"/> class. /// </summary> /// /// <param name="partitionContext">Contains information about the partition this instance will be associated with.</param> /// <param name="partitionManager">Interacts with the storage system, dealing with the creation of checkpoints.</param> /// <param name="ownerIdentifier">The identifier of the associated <see cref="EventProcessor" /> instance.</param> /// internal CheckpointManager(PartitionContext partitionContext, PartitionManager partitionManager, string ownerIdentifier) { Context = partitionContext; Manager = partitionManager; OwnerIdentifier = ownerIdentifier; }
/// <summary> /// Initializes a new instance of the <see cref="PartitionContext"/> class. /// </summary> /// /// <param name="eventHubName">The name of the specific Event Hub this context is associated with, relative to the Event Hubs namespace that contains it.</param> /// <param name="consumerGroup">The name of the consumer group this context is associated with.</param> /// <param name="partitionId">The identifier of the Event Hub partition this context is associated with.</param> /// <param name="partitionManager">Interacts with the storage system with responsibility for creation of checkpoints.</param> /// <param name="ownerIdentifier">The identifier of the associated <see cref="EventProcessor{T}" /> instance.</param> /// protected internal PartitionContext(string eventHubName, string consumerGroup, string partitionId, string ownerIdentifier, PartitionManager partitionManager) { Guard.ArgumentNotNullOrEmpty(nameof(eventHubName), eventHubName); Guard.ArgumentNotNullOrEmpty(nameof(consumerGroup), consumerGroup); Guard.ArgumentNotNullOrEmpty(nameof(partitionId), partitionId); Guard.ArgumentNotNullOrEmpty(nameof(ownerIdentifier), ownerIdentifier); Guard.ArgumentNotNull(nameof(partitionManager), partitionManager); EventHubName = eventHubName; ConsumerGroup = consumerGroup; PartitionId = partitionId; OwnerIdentifier = ownerIdentifier; Manager = partitionManager; }
/// <summary> /// Initializes a new instance of the <see cref="EventProcessor"/> class. /// </summary> /// /// <param name="consumerGroup">The name of the consumer group this event processor is associated with. Events are read in the context of this group.</param> /// <param name="eventHubClient">The client used to interact with the Azure Event Hubs service.</param> /// <param name="partitionProcessorFactory">Creates an instance of a class implementing the <see cref="IPartitionProcessor" /> interface.</param> /// <param name="partitionManager">Interacts with the storage system, dealing with ownership and checkpoints.</param> /// <param name="options">The set of options to use for this event processor.</param> /// /// <remarks> /// Ownership of the <paramref name="eventHubClient" /> is assumed to be responsibility of the caller; this /// processor will delegate operations to it, but will not perform any clean-up tasks, such as closing or /// disposing of the instance. /// </remarks> /// public EventProcessor(string consumerGroup, EventHubClient eventHubClient, Func <PartitionContext, CheckpointManager, IPartitionProcessor> partitionProcessorFactory, PartitionManager partitionManager, EventProcessorOptions options = default) { Guard.ArgumentNotNullOrEmpty(nameof(consumerGroup), consumerGroup); Guard.ArgumentNotNull(nameof(eventHubClient), eventHubClient); Guard.ArgumentNotNull(nameof(partitionProcessorFactory), partitionProcessorFactory); Guard.ArgumentNotNull(nameof(partitionManager), partitionManager); InnerClient = eventHubClient; ConsumerGroup = consumerGroup; PartitionProcessorFactory = partitionProcessorFactory; Manager = partitionManager; Options = options?.Clone() ?? new EventProcessorOptions(); Identifier = Guid.NewGuid().ToString(); PartitionPumps = new ConcurrentDictionary <string, PartitionPump>(); }
/// <summary> /// Initializes a new instance of the <see cref="PartitionLoadBalancer"/> class. /// </summary> /// /// <param name="storageManager">Responsible for creation of checkpoints and for ownership claim.</param> /// <param name="identifier">The identifier of the EventProcessorClient that owns this load balancer.</param> /// <param name="consumerGroup">The name of the consumer group this load balancer is associated with.</param> /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace that the processor is associated with.</param> /// <param name="eventHubName">The name of the Event Hub that the processor is associated with.</param> /// <param name="ownershipExpiration">The minimum amount of time for an ownership to be considered expired without further updates.</param> /// public PartitionLoadBalancer(PartitionManager storageManager, string identifier, string consumerGroup, string fullyQualifiedNamespace, string eventHubName, TimeSpan ownershipExpiration) { Argument.AssertNotNull(storageManager, nameof(storageManager)); Argument.AssertNotNullOrEmpty(identifier, nameof(identifier)); Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup)); Argument.AssertNotNullOrEmpty(fullyQualifiedNamespace, nameof(fullyQualifiedNamespace)); Argument.AssertNotNullOrEmpty(eventHubName, nameof(eventHubName)); StorageManager = storageManager; OwnerIdentifier = identifier; FullyQualifiedNamespace = fullyQualifiedNamespace; EventHubName = eventHubName; ConsumerGroup = consumerGroup; OwnershipExpiration = ownershipExpiration; }
/// <summary> /// Initializes a new instance of the <see cref="EventProcessor{T}"/> class. /// </summary> /// /// <param name="consumerGroup">The name of the consumer group this event processor is associated with. Events are read in the context of this group.</param> /// <param name="eventHubClient">The client used to interact with the Azure Event Hubs service.</param> /// <param name="partitionProcessorFactory">Creates a partition processor instance for the associated <see cref="PartitionContext" />.</param> /// <param name="partitionManager">Interacts with the storage system with responsibility for creation of checkpoints and for ownership claim.</param> /// <param name="options">The set of options to use for this event processor.</param> /// /// <remarks> /// Ownership of the <paramref name="eventHubClient" /> is assumed to be responsibility of the caller; this /// processor will delegate operations to it, but will not perform any clean-up tasks, such as closing or /// disposing of the instance. /// </remarks> /// public EventProcessor(string consumerGroup, EventHubClient eventHubClient, Func <PartitionContext, BasePartitionProcessor> partitionProcessorFactory, PartitionManager partitionManager, EventProcessorOptions options = default) { Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup)); Argument.AssertNotNull(eventHubClient, nameof(eventHubClient)); Argument.AssertNotNull(partitionProcessorFactory, nameof(partitionProcessorFactory)); Argument.AssertNotNull(partitionManager, nameof(partitionManager)); InnerClient = eventHubClient; ConsumerGroup = consumerGroup; PartitionProcessorFactory = partitionProcessorFactory; Manager = partitionManager; Options = options?.Clone() ?? new EventProcessorOptions(); Identifier = Guid.NewGuid().ToString(); PartitionPumps = new ConcurrentDictionary <string, PartitionPump>(); }
/// <summary> /// Initializes a new instance of the <see cref="PartitionContext"/> class. /// </summary> /// /// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace this context is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param> /// <param name="eventHubName">The name of the specific Event Hub this context is associated with, relative to the Event Hubs namespace that contains it.</param> /// <param name="consumerGroup">The name of the consumer group this context is associated with.</param> /// <param name="partitionId">The identifier of the Event Hub partition this context is associated with.</param> /// <param name="partitionManager">Interacts with the storage system with responsibility for creation of checkpoints.</param> /// <param name="ownerIdentifier">The identifier of the associated <see cref="EventProcessorClient" /> instance.</param> /// protected internal PartitionContext(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string partitionId, string ownerIdentifier, PartitionManager partitionManager) { Argument.AssertNotNullOrEmpty(fullyQualifiedNamespace, nameof(fullyQualifiedNamespace)); Argument.AssertNotNullOrEmpty(eventHubName, nameof(eventHubName)); Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup)); Argument.AssertNotNullOrEmpty(partitionId, nameof(partitionId)); Argument.AssertNotNullOrEmpty(ownerIdentifier, nameof(ownerIdentifier)); Argument.AssertNotNull(partitionManager, nameof(partitionManager)); FullyQualifiedNamespace = fullyQualifiedNamespace; EventHubName = eventHubName; ConsumerGroup = consumerGroup; PartitionId = partitionId; OwnerIdentifier = ownerIdentifier; Manager = partitionManager; }
/// <summary> /// Initializes a new instance of the <see cref="EventProcessor{T}"/> class. /// </summary> /// /// <param name="consumerGroup">The name of the consumer group this event processor is associated with. Events are read in the context of this group.</param> /// <param name="eventHubClient">The client used to interact with the Azure Event Hubs service.</param> /// <param name="partitionManager">Interacts with the storage system with responsibility for creation of checkpoints and for ownership claim.</param> /// <param name="options">The set of options to use for this event processor.</param> /// /// <remarks> /// Ownership of the <paramref name="eventHubClient" /> is assumed to be responsibility of the caller; this /// processor will delegate operations to it, but will not perform any clean-up tasks, such as closing or /// disposing of the instance. /// </remarks> /// public EventProcessor(string consumerGroup, EventHubClient eventHubClient, PartitionManager partitionManager, EventProcessorOptions options = default) : this(consumerGroup, eventHubClient, partitionContext => new T(), partitionManager, options) { }