Skip to content

Commit be8b01d

Browse files
authored
Make CheckpointStore source-shareable (#17017)
So it can be consumed from the webjobs extension
1 parent 146c420 commit be8b01d

File tree

6 files changed

+456
-37
lines changed

6 files changed

+456
-37
lines changed

sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Azure.Messaging.EventHubs.Processor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<Import Project="$(MSBuildThisFileDirectory)..\..\Azure.Messaging.EventHubs.Shared\src\Azure.Messaging.EventHubs.Shared.Diagnostics.projitems" Label="Diagnostics" />
3434
<Import Project="$(MSBuildThisFileDirectory)..\..\Azure.Messaging.EventHubs.Shared\src\Azure.Messaging.EventHubs.Shared.Authorization.projitems" Label="Authorization" />
3535
<Import Project="$(MSBuildThisFileDirectory)..\..\Azure.Messaging.EventHubs.Shared\src\Azure.Messaging.EventHubs.Shared.Processor.projitems" Label="Processor" />
36+
<Import Project="$(MSBuildThisFileDirectory)..\..\Azure.Messaging.EventHubs.Shared\src\Azure.Messaging.EventHubs.Shared.BlobCheckpointStore.projitems" Label="CheckpointStore" />
3637

3738
<!-- Import Azure.Core shared source -->
3839
<ItemGroup>
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using Azure.Messaging.EventHubs.Processor.Diagnostics;
5+
6+
namespace Azure.Messaging.EventHubs.Processor
7+
{
8+
/// <summary>
9+
/// A storage blob service that keeps track of checkpoints and ownership.
10+
/// </summary>
11+
///
12+
internal sealed partial class BlobsCheckpointStore
13+
{
14+
/// <summary>
15+
/// Initializes the <see cref="BlobsCheckpointStore"/> type.
16+
/// </summary>
17+
#pragma warning disable CA1810 // Initialize static fields inline
18+
static BlobsCheckpointStore()
19+
{
20+
BlobsResourceDoesNotExist = Resources.BlobsResourceDoesNotExist;
21+
}
22+
#pragma warning restore CA1810
23+
24+
/// <summary>
25+
/// The instance of <see cref="BlobEventStoreEventSource" /> which can be mocked for testing.
26+
/// </summary>
27+
///
28+
internal BlobEventStoreEventSource Logger { get; set; } = BlobEventStoreEventSource.Log;
29+
30+
/// <summary>
31+
/// Indicates that an attempt to retrieve a list of ownership has completed.
32+
/// </summary>
33+
///
34+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
35+
/// <param name="eventHubName">The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it.</param>
36+
/// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param>
37+
/// <param name="ownershipCount">The amount of ownership received from the storage service.</param>
38+
///
39+
partial void ListOwnershipComplete(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, int ownershipCount) =>
40+
Logger.ListOwnershipComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, ownershipCount);
41+
42+
/// <summary>
43+
/// Indicates that an unhandled exception was encountered while retrieving a list of ownership.
44+
/// </summary>
45+
///
46+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
47+
/// <param name="eventHubName">The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it.</param>
48+
/// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param>
49+
/// <param name="errorMessage">The message for the exception that occurred.</param>
50+
///
51+
partial void ListOwnershipError(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage) =>
52+
Logger.ListOwnershipError(fullyQualifiedNamespace, eventHubName, consumerGroup, errorMessage);
53+
54+
/// <summary>
55+
/// Indicates that an attempt to retrieve a list of ownership has started.
56+
/// </summary>
57+
///
58+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership are associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
59+
/// <param name="eventHubName">The name of the specific Event Hub the ownership are associated with, relative to the Event Hubs namespace that contains it.</param>
60+
/// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param>
61+
///
62+
partial void ListOwnershipStart(string fullyQualifiedNamespace, string eventHubName, string consumerGroup) =>
63+
Logger.ListOwnershipStart(fullyQualifiedNamespace, eventHubName, consumerGroup);
64+
65+
/// <summary>
66+
/// Indicates that an attempt to retrieve a list of checkpoints has completed.
67+
/// </summary>
68+
///
69+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
70+
/// <param name="eventHubName">The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it.</param>
71+
/// <param name="consumerGroup">The name of the consumer group the checkpoints are associated with.</param>
72+
/// <param name="checkpointCount">The amount of checkpoints received from the storage service.</param>
73+
///
74+
partial void ListCheckpointsComplete(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, int checkpointCount) =>
75+
Logger.ListCheckpointsComplete(fullyQualifiedNamespace, eventHubName, consumerGroup, checkpointCount);
76+
77+
/// <summary>
78+
/// Indicates that an unhandled exception was encountered while retrieving a list of checkpoints.
79+
/// </summary>
80+
///
81+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
82+
/// <param name="eventHubName">The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it.</param>
83+
/// <param name="consumerGroup">The name of the consumer group the ownership are associated with.</param>
84+
/// <param name="errorMessage">The message for the exception that occurred.</param>
85+
///
86+
partial void ListCheckpointsError(string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage) =>
87+
Logger.ListCheckpointsError(fullyQualifiedNamespace, eventHubName, consumerGroup, errorMessage);
88+
89+
/// <summary>
90+
/// Indicates that invalid checkpoint data was found during an attempt to retrieve a list of checkpoints.
91+
/// </summary>
92+
///
93+
/// <param name="partitionId">The identifier of the partition the data is associated with.</param>
94+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the data is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
95+
/// <param name="eventHubName">The name of the specific Event Hub the data is associated with, relative to the Event Hubs namespace that contains it.</param>
96+
/// <param name="consumerGroup">The name of the consumer group the data is associated with.</param>
97+
///
98+
partial void InvalidCheckpointFound(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup) =>
99+
Logger.InvalidCheckpointFound(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup);
100+
101+
/// <summary>
102+
/// Indicates that an attempt to retrieve a list of checkpoints has started.
103+
/// </summary>
104+
///
105+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoints are associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
106+
/// <param name="eventHubName">The name of the specific Event Hub the checkpoints are associated with, relative to the Event Hubs namespace that contains it.</param>
107+
/// <param name="consumerGroup">The name of the consumer group the checkpoints are associated with.</param>
108+
///
109+
partial void ListCheckpointsStart(string fullyQualifiedNamespace, string eventHubName, string consumerGroup) =>
110+
Logger.ListCheckpointsStart(fullyQualifiedNamespace, eventHubName, consumerGroup);
111+
112+
/// <summary>
113+
/// Indicates that an unhandled exception was encountered while updating a checkpoint.
114+
/// </summary>
115+
///
116+
/// <param name="partitionId">The identifier of the partition being checkpointed.</param>
117+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
118+
/// <param name="eventHubName">The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it.</param>
119+
/// <param name="consumerGroup">The name of the consumer group the checkpoint is associated with.</param>
120+
/// <param name="errorMessage">The message for the exception that occurred.</param>
121+
///
122+
partial void UpdateCheckpointError(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string errorMessage) =>
123+
Logger.UpdateCheckpointError(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, errorMessage);
124+
125+
/// <summary>
126+
/// Indicates that an attempt to update a checkpoint has completed.
127+
/// </summary>
128+
///
129+
/// <param name="partitionId">The identifier of the partition being checkpointed.</param>
130+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
131+
/// <param name="eventHubName">The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it.</param>
132+
/// <param name="consumerGroup">The name of the consumer group the checkpoint is associated with.</param>
133+
///
134+
partial void UpdateCheckpointComplete(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup) =>
135+
Logger.UpdateCheckpointComplete(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup);
136+
137+
/// <summary>
138+
/// Indicates that an attempt to create/update a checkpoint has started.
139+
/// </summary>
140+
///
141+
/// <param name="partitionId">The identifier of the partition being checkpointed.</param>
142+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the checkpoint is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
143+
/// <param name="eventHubName">The name of the specific Event Hub the checkpoint is associated with, relative to the Event Hubs namespace that contains it.</param>
144+
/// <param name="consumerGroup">The name of the consumer group the checkpoint is associated with.</param>
145+
///
146+
partial void UpdateCheckpointStart(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup) =>
147+
Logger.UpdateCheckpointStart(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup);
148+
149+
/// <summary>
150+
/// Indicates that an attempt to retrieve claim partition ownership has completed.
151+
/// </summary>
152+
///
153+
/// <param name="partitionId">The identifier of the partition being claimed.</param>
154+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
155+
/// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it.</param>
156+
/// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param>
157+
/// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</param>
158+
///
159+
partial void ClaimOwnershipComplete(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier) =>
160+
Logger.ClaimOwnershipComplete(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier);
161+
162+
/// <summary>
163+
/// Indicates that an exception was encountered while attempting to retrieve claim partition ownership.
164+
/// </summary>
165+
///
166+
/// <param name="partitionId">The identifier of the partition being claimed.</param>
167+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
168+
/// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it.</param>
169+
/// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param>
170+
/// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</param>
171+
/// <param name="errorMessage">The message for the exception that occurred.</param>
172+
///
173+
partial void ClaimOwnershipError(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier, string errorMessage) =>
174+
Logger.ClaimOwnershipError(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier, errorMessage);
175+
176+
/// <summary>
177+
/// Indicates that ownership was unable to be claimed.
178+
/// </summary>
179+
///
180+
/// <param name="partitionId">The identifier of the partition being claimed.</param>
181+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
182+
/// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it.</param>
183+
/// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param>
184+
/// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</param>
185+
/// <param name="message">The message for the failure.</param>
186+
///
187+
partial void OwnershipNotClaimable(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier, string message) =>
188+
Logger.OwnershipNotClaimable(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier, message);
189+
190+
/// <summary>
191+
/// Indicates that ownership was successfully claimed.
192+
/// </summary>
193+
///
194+
/// <param name="partitionId">The identifier of the partition being claimed.</param>
195+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
196+
/// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it.</param>
197+
/// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param>
198+
/// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</param>
199+
///
200+
partial void OwnershipClaimed(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier) =>
201+
Logger.OwnershipClaimed(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier);
202+
203+
/// <summary>
204+
/// Indicates that an attempt to claim a partition ownership has started.
205+
/// </summary>
206+
///
207+
/// <param name="partitionId">The identifier of the partition being claimed.</param>
208+
/// <param name="fullyQualifiedNamespace">The fully qualified Event Hubs namespace the ownership is associated with. This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param>
209+
/// <param name="eventHubName">The name of the specific Event Hub the ownership is associated with, relative to the Event Hubs namespace that contains it.</param>
210+
/// <param name="consumerGroup">The name of the consumer group the ownership is associated with.</param>
211+
/// <param name="ownerIdentifier">The identifier of the processor that attempted to claim the ownership for.</param>
212+
///
213+
partial void ClaimOwnershipStart(string partitionId, string fullyQualifiedNamespace, string eventHubName, string consumerGroup, string ownerIdentifier) =>
214+
Logger.ClaimOwnershipStart(partitionId, fullyQualifiedNamespace, eventHubName, consumerGroup, ownerIdentifier);
215+
216+
/// <summary>
217+
/// Indicates that a <see cref="BlobsCheckpointStore" /> was created.
218+
/// </summary>
219+
///
220+
/// <param name="typeName">The type name for the checkpoint store.</param>
221+
/// <param name="accountName">The Storage account name corresponding to the associated container client.</param>
222+
/// <param name="containerName">The name of the associated container client.</param>
223+
///
224+
partial void BlobsCheckpointStoreCreated(string typeName, string accountName, string containerName) =>
225+
Logger.BlobsCheckpointStoreCreated(typeName, accountName, containerName);
226+
}
227+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
<HasSharedItems>true</HasSharedItems>
6+
<SharedGUID>826d9924-8c85-4db1-9407-1b133a3d953f</SharedGUID>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<Import_RootNamespace>Azure.Messaging.EventHubs.Primitives</Import_RootNamespace>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<Compile Include="$(MSBuildThisfileDirectory)BlobCheckpointStore\*.cs" Link="SharedSource\BlobCheckpointStore\%(Filename)%(Extension)" />
15+
</ItemGroup>
16+
</Project>

sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/Storage/BlobMetadataKey.cs renamed to sdk/eventhub/Azure.Messaging.EventHubs.Shared/src/BlobCheckpointStore/BlobMetadataKey.cs

File renamed without changes.

0 commit comments

Comments
 (0)