Skip to content

Commit 2c0cc4e

Browse files
Add more system event mappings (Azure#19280)
* Add more system event mappings * Update comment * PR FB
1 parent 967247f commit 2c0cc4e

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

sdk/eventgrid/Azure.Messaging.EventGrid/api/Azure.Messaging.EventGrid.netstandard2.0.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public static partial class SystemEventNames
128128
public const string MediaLiveEventIncomingVideoStreamsOutOfSync = "Microsoft.Media.LiveEventIncomingVideoStreamsOutOfSync";
129129
public const string MediaLiveEventIngestHeartbeat = "Microsoft.Media.LiveEventIngestHeartbeat";
130130
public const string MediaLiveEventTrackDiscontinuityDetected = "Microsoft.Media.LiveEventTrackDiscontinuityDetected";
131+
public const string RedisExportRDBCompleted = "Microsoft.Cache.ExportRDBCompleted";
132+
public const string RedisImportRDBCompleted = "Microsoft.Cache.ImportRDBCompleted";
133+
public const string RedisPatchingCompleted = "Microsoft.Cache.PatchingCompleted";
134+
public const string RedisScalingCompleted = "Microsoft.Cache.ScalingCompleted";
131135
public const string ResourceActionCancel = "Microsoft.Resources.ResourceActionCancel";
132136
public const string ResourceActionFailure = "Microsoft.Resources.ResourceActionFailure";
133137
public const string ResourceActionSuccess = "Microsoft.Resources.ResourceActionSuccess";
@@ -141,6 +145,8 @@ public static partial class SystemEventNames
141145
public const string ServiceBusActiveMessagesAvailableWithNoListeners = "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners";
142146
public const string ServiceBusDeadletterMessagesAvailablePeriodicNotifications = "Microsoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotifications";
143147
public const string ServiceBusDeadletterMessagesAvailableWithNoListener = "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener";
148+
public const string SignalRServiceClientConnectionConnected = "Microsoft.SignalRService.ClientConnectionConnected";
149+
public const string SignalRServiceClientConnectionDisconnected = "Microsoft.SignalRService.ClientConnectionDisconnected";
144150
public const string StorageBlobCreated = "Microsoft.Storage.BlobCreated";
145151
public const string StorageBlobDeleted = "Microsoft.Storage.BlobDeleted";
146152
public const string StorageBlobRenamed = "Microsoft.Storage.BlobRenamed";

sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventExtensions.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static object AsSystemEventData(string eventType, JsonElement data)
2222
}
2323
}
2424

25-
private static readonly IReadOnlyDictionary<string, Func<JsonElement, object>> s_systemEventDeserializers = new Dictionary<string, Func<JsonElement, object>>(StringComparer.OrdinalIgnoreCase)
25+
internal static readonly IReadOnlyDictionary<string, Func<JsonElement, object>> s_systemEventDeserializers = new Dictionary<string, Func<JsonElement, object>>(StringComparer.OrdinalIgnoreCase)
2626
{
2727
// KEEP THIS SORTED BY THE NAME OF THE PUBLISHING SERVICE
2828
// Add handling for additional event types here.
@@ -132,12 +132,22 @@ public static object AsSystemEventData(string eventType, JsonElement data)
132132
{ SystemEventNames.ResourceActionFailure, ResourceActionFailureEventData.DeserializeResourceActionFailureEventData },
133133
{ SystemEventNames.ResourceActionCancel, ResourceActionCancelEventData.DeserializeResourceActionCancelEventData },
134134

135+
// Redis
136+
{ SystemEventNames.RedisExportRDBCompleted, RedisExportRDBCompletedEventData.DeserializeRedisExportRDBCompletedEventData },
137+
{ SystemEventNames.RedisImportRDBCompleted, RedisImportRDBCompletedEventData.DeserializeRedisImportRDBCompletedEventData },
138+
{ SystemEventNames.RedisPatchingCompleted, RedisPatchingCompletedEventData.DeserializeRedisPatchingCompletedEventData },
139+
{ SystemEventNames.RedisScalingCompleted, RedisScalingCompletedEventData.DeserializeRedisScalingCompletedEventData },
140+
135141
// ServiceBus events
136142
{ SystemEventNames.ServiceBusActiveMessagesAvailableWithNoListeners, ServiceBusActiveMessagesAvailableWithNoListenersEventData.DeserializeServiceBusActiveMessagesAvailableWithNoListenersEventData },
137143
{ SystemEventNames.ServiceBusDeadletterMessagesAvailableWithNoListener, ServiceBusDeadletterMessagesAvailableWithNoListenersEventData.DeserializeServiceBusDeadletterMessagesAvailableWithNoListenersEventData },
138144
{ SystemEventNames.ServiceBusActiveMessagesAvailablePeriodicNotifications, ServiceBusActiveMessagesAvailablePeriodicNotificationsEventData.DeserializeServiceBusActiveMessagesAvailablePeriodicNotificationsEventData },
139145
{ SystemEventNames.ServiceBusDeadletterMessagesAvailablePeriodicNotifications, ServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData.DeserializeServiceBusDeadletterMessagesAvailablePeriodicNotificationsEventData },
140146

147+
// SignalR
148+
{ SystemEventNames.SignalRServiceClientConnectionConnected, SignalRServiceClientConnectionConnectedEventData.DeserializeSignalRServiceClientConnectionConnectedEventData },
149+
{ SystemEventNames.SignalRServiceClientConnectionDisconnected, SignalRServiceClientConnectionDisconnectedEventData.DeserializeSignalRServiceClientConnectionDisconnectedEventData },
150+
141151
// Storage events
142152
{ SystemEventNames.StorageBlobCreated, StorageBlobCreatedEventData.DeserializeStorageBlobCreatedEventData },
143153
{ SystemEventNames.StorageBlobDeleted, StorageBlobDeletedEventData.DeserializeStorageBlobDeletedEventData },

sdk/eventgrid/Azure.Messaging.EventGrid/src/Customization/SystemEventNames.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public static class SystemEventNames
161161
/// <see cref="ContainerRegistryChartPushedEventData"/> system event.
162162
/// </summary>
163163
public const string ContainerRegistryChartPushed = "Microsoft.ContainerRegistry.ChartPushed";
164+
164165
#endregion
165166

166167
#region Device events
@@ -682,5 +683,45 @@ public static class SystemEventNames
682683
/// </summary>
683684
public const string WebAppServicePlanUpdated = "Microsoft.Web.AppServicePlanUpdated";
684685
#endregion
686+
687+
#region Redis
688+
/// <summary>
689+
/// The value of the Event Type stored in <see cref="EventGridEvent.EventType"/> and <see cref="CloudEvent.Type"/> for the
690+
/// <see cref="RedisExportRDBCompletedEventData"/> system event.
691+
/// </summary>
692+
public const string RedisExportRDBCompleted = "Microsoft.Cache.ExportRDBCompleted";
693+
694+
/// <summary>
695+
/// The value of the Event Type stored in <see cref="EventGridEvent.EventType"/> and <see cref="CloudEvent.Type"/> for the
696+
/// <see cref="RedisImportRDBCompletedEventData"/> system event.
697+
/// </summary>
698+
public const string RedisImportRDBCompleted = "Microsoft.Cache.ImportRDBCompleted";
699+
700+
/// <summary>
701+
/// The value of the Event Type stored in <see cref="EventGridEvent.EventType"/> and <see cref="CloudEvent.Type"/> for the
702+
/// <see cref="RedisPatchingCompletedEventData"/> system event.
703+
/// </summary>
704+
public const string RedisPatchingCompleted = "Microsoft.Cache.PatchingCompleted";
705+
706+
/// <summary>
707+
/// The value of the Event Type stored in <see cref="EventGridEvent.EventType"/> and <see cref="CloudEvent.Type"/> for the
708+
/// <see cref="RedisScalingCompletedEventData"/> system event.
709+
/// </summary>
710+
public const string RedisScalingCompleted = "Microsoft.Cache.ScalingCompleted";
711+
#endregion
712+
713+
#region SignalR
714+
/// <summary>
715+
/// The value of the Event Type stored in <see cref="EventGridEvent.EventType"/> and <see cref="CloudEvent.Type"/> for the
716+
/// <see cref="SignalRServiceClientConnectionConnectedEventData"/> system event.
717+
/// </summary>
718+
public const string SignalRServiceClientConnectionConnected = "Microsoft.SignalRService.ClientConnectionConnected";
719+
720+
/// <summary>
721+
/// The value of the Event Type stored in <see cref="EventGridEvent.EventType"/> and <see cref="CloudEvent.Type"/> for the
722+
/// <see cref="SignalRServiceClientConnectionDisconnectedEventData"/> system event.
723+
/// </summary>
724+
public const string SignalRServiceClientConnectionDisconnected = "Microsoft.SignalRService.ClientConnectionDisconnected";
725+
#endregion
685726
}
686727
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Linq;
5+
using System.Reflection;
6+
using Azure.Messaging.EventGrid.SystemEvents;
7+
using NUnit.Framework;
8+
9+
namespace Azure.Messaging.EventGrid.Tests
10+
{
11+
public class SystemEventTests
12+
{
13+
[Test]
14+
public void MappingContainsAllSystemEvents()
15+
{
16+
foreach (var systemEvent in Assembly.GetAssembly(typeof(EventGridEvent)).GetTypes().Where(t => t.Name.EndsWith("EventData")))
17+
{
18+
// skip base types
19+
if (systemEvent == typeof(ContainerRegistryArtifactEventData) ||
20+
systemEvent == typeof(ContainerRegistryEventData))
21+
{
22+
continue;
23+
}
24+
Assert.IsTrue(
25+
SystemEventExtensions.s_systemEventDeserializers.Values.Any(
26+
f => f.Method.ReturnType == systemEvent), systemEvent.Name);
27+
}
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)