forked from Azure/iotedge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix 8419918]: fixed message counts metrics (Azure#3980)
* fixed message count metrics
- Loading branch information
Showing
8 changed files
with
516 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
edge-hub/core/src/Microsoft.Azure.Devices.Routing.Core/MessageQueueIdHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
namespace Microsoft.Azure.Devices.Routing.Core | ||
{ | ||
using System; | ||
|
||
public static class MessageQueueIdHelper | ||
{ | ||
public const string MessageQueueIdDelimiter = "_Pri"; | ||
|
||
// The actual ID for the underlying store is of string format: <endpointId>_Pri<priority> | ||
// We need to maintain backwards compatibility for existing sequential stores that don't have the "_Pri<x>" suffix. | ||
// We use the default priority (2,000,000,000) for this, which means the store ID is just the endpoint ID. | ||
public static string GetMessageQueueId(string endpointId, uint priority) => priority == RouteFactory.DefaultPriority ? endpointId : $"{endpointId}{MessageQueueIdDelimiter}{priority}"; | ||
|
||
public static (string, uint) ParseMessageQueueId(string messageQueueId) | ||
{ | ||
var idx = messageQueueId.LastIndexOf(MessageQueueIdDelimiter); | ||
if (idx < 0) | ||
{ | ||
return (messageQueueId, RouteFactory.DefaultPriority); | ||
} | ||
|
||
var endpointId = messageQueueId.Substring(0, idx); | ||
var priority = messageQueueId.Substring(idx + MessageQueueIdDelimiter.Length); | ||
if (uint.TryParse(priority, out var priorityNum)) | ||
{ | ||
return (endpointId, priorityNum); | ||
} | ||
else | ||
{ | ||
return (messageQueueId, RouteFactory.DefaultPriority); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.