Skip to content

Commit

Permalink
update direct
Browse files Browse the repository at this point in the history
  • Loading branch information
NaluTripician committed May 2, 2024
1 parent 2ad1a1b commit 039be0c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
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
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);
}
}
15 changes: 15 additions & 0 deletions Microsoft.Azure.Cosmos/src/direct/IServiceRetryParams.cs
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);
}
}
22 changes: 22 additions & 0 deletions Microsoft.Azure.Cosmos/src/direct/PerformanceCounter.cs
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; }
}
}

0 comments on commit 039be0c

Please sign in to comment.