-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ad1a1b
commit 039be0c
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Microsoft.Azure.Cosmos/src/direct/Azure.Core/AppContextSwitchHelper.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,47 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
// This File is copied from Azure.Core repo i.e. https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/src/Shared/AppContextSwitchHelper.cs | ||
|
||
#nullable enable | ||
#if NETSTANDARD2_0_OR_GREATER | ||
namespace Azure.Core | ||
{ | ||
using System; | ||
/// <summary> | ||
/// Helper for interacting with AppConfig settings and their related Environment variable settings. | ||
/// </summary> | ||
internal static class AppContextSwitchHelper | ||
{ | ||
/// <summary> | ||
/// Determines if either an AppContext switch or its corresponding Environment Variable is set | ||
/// </summary> | ||
/// <param name="appContexSwitchName">Name of the AppContext switch.</param> | ||
/// <param name="environmentVariableName">Name of the Environment variable.</param> | ||
/// <returns>If the AppContext switch has been set, returns the value of the switch. | ||
/// If the AppContext switch has not been set, returns the value of the environment variable. | ||
/// False if neither is set. | ||
/// </returns> | ||
public static bool GetConfigValue(string appContexSwitchName, string environmentVariableName) | ||
{ | ||
// First check for the AppContext switch, giving it priority over the environment variable. | ||
if (AppContext.TryGetSwitch(appContexSwitchName, out bool value)) | ||
{ | ||
return value; | ||
} | ||
// AppContext switch wasn't used. Check the environment variable. | ||
string? envVar = Environment.GetEnvironmentVariable(environmentVariableName); | ||
if (envVar != null | ||
&& (envVar.Equals("true", StringComparison.OrdinalIgnoreCase) | ||
|| envVar.Equals("1", StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
return true; | ||
} | ||
|
||
// Default to false. | ||
return false; | ||
} | ||
} | ||
} | ||
#endif |
16 changes: 16 additions & 0 deletions
16
Microsoft.Azure.Cosmos/src/direct/IServiceConfigurationReaderExtension.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,16 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Documents | ||
{ | ||
/// <summary> | ||
/// Interface extension for IServiceConfigurationReader, should be consolidated with IServiceConfigurationReader in the future | ||
/// This is needed because the way compute uses SDK is using a V3 OSS clone of our public v3 repo. | ||
/// So, the moment you change some interface in the Direct/ Shared Files, it immediately gets reflected in the OSS code path | ||
/// </summary> | ||
internal interface IServiceConfigurationReaderExtension : IServiceConfigurationReader | ||
{ | ||
IServiceRetryParams TryGetServiceRetryParams(DocumentServiceRequest documentServiceRequest); | ||
} | ||
} |
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,15 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Documents | ||
{ | ||
/// <summary> | ||
/// Retry params that every service can configure | ||
/// Add more api's that control retry as needed, currently only exposes overall timeout | ||
/// </summary> | ||
internal interface IServiceRetryParams | ||
{ | ||
public bool TryGetRetryTimeoutInSeconds(out int retryTimeoutInSeconds); | ||
} | ||
} |
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,22 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Documents.Test.Analytics | ||
{ | ||
using System; | ||
|
||
[Serializable] | ||
public sealed class PerformanceCounter | ||
{ | ||
public string CounterName { get; set; } | ||
|
||
public double Average { get; set; } | ||
|
||
public double Percentile10 { get; set; } | ||
|
||
public double Percentile90 { get; set; } | ||
|
||
public double Percentile99 { get; set; } | ||
} | ||
} |