Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Datadog.Trace.Configuration.Schema;
using Datadog.Trace.DataStreamsMonitoring;
using Datadog.Trace.DataStreamsMonitoring.Utils;
Expand Down Expand Up @@ -463,6 +464,11 @@ internal static void TryInjectHeaders<TTopicPartitionMarker, TMessage>(

var duckTask = adminClient.DescribeClusterAsync(options);

if (duckTask.Status == TaskStatus.RanToCompletion)
{
return duckTask.Result?.ClusterId;
}

var originalContext = SynchronizationContext.Current;
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ internal interface IXunitTestMethodRunnerV3
/// </summary>
/// <param name="context">Test context</param>
/// <param name="testCase">Test case</param>
IDuckTypeTask<object> RunTestCase(object context, object testCase);
IDuckTypeValueTask<object> RunTestCase(object context, object testCase);
}
13 changes: 13 additions & 0 deletions tracer/src/Datadog.Trace/DuckTyping/IDuckTypeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// </copyright>

#nullable enable

using System.Threading.Tasks;

namespace Datadog.Trace.DuckTyping;

/// <summary>
Expand All @@ -12,6 +15,11 @@ namespace Datadog.Trace.DuckTyping;
/// <typeparam name="T">Type of the result</typeparam>
public interface IDuckTypeTask<out T> : IDuckType
{
/// <summary>
/// Gets the status of the task
/// </summary>
TaskStatus Status { get; }

/// <summary>
/// Gets the result of the task
/// </summary>
Expand All @@ -29,6 +37,11 @@ public interface IDuckTypeTask<out T> : IDuckType
/// </summary>
public interface IDuckTypeTask : IDuckType
{
/// <summary>
/// Gets the status of the task
/// </summary>
TaskStatus Status { get; }

/// <summary>
/// Gets the awaiter for the task
/// </summary>
Expand Down
47 changes: 47 additions & 0 deletions tracer/src/Datadog.Trace/DuckTyping/IDuckTypeValueTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// <copyright file="IDuckTypeValueTask.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

#nullable enable
namespace Datadog.Trace.DuckTyping;

/// <summary>
/// Duck type value task interface
/// </summary>
/// <typeparam name="T">Type of the result</typeparam>
public interface IDuckTypeValueTask<out T> : IDuckType
{
/// <summary>
/// Gets a value indicating whether the value task completed successfully
/// </summary>
bool IsCompletedSuccessfully { get; }

/// <summary>
/// Gets the result of the value task
/// </summary>
T? Result { get; }

/// <summary>
/// Gets the awaiter for the value task
/// </summary>
/// <returns>Awaiter instance</returns>
IDuckTypeAwaiter<T> GetAwaiter();
}

/// <summary>
/// Duck type value task interface
/// </summary>
public interface IDuckTypeValueTask : IDuckType
{
/// <summary>
/// Gets a value indicating whether the value task completed successfully
/// </summary>
bool IsCompletedSuccessfully { get; }

/// <summary>
/// Gets the awaiter for the value task
/// </summary>
/// <returns>Awaiter instance</returns>
IDuckTypeAwaiter GetAwaiter();
}
Loading