Skip to content

[Feature] Consider Adding API to DurableTaskClient for Fetching Task Hub Metadata #336

@wsugarman

Description

@wsugarman

My team runs two applications: a function app that uses durable functions as well as a web app. From that web app, clients can trigger asynchronous operations that submit orchestrations to the Task Hub via a DurableTaskClient. However, we run in K8s and so we have a number of health checks that run periodically. Can the web app communicate with its Azure Storage account? Its Azure SQL Server DB? Similarly, we have written a custom one for DTFx.

A simple one could be invoke a read-only method like GetAllInstancesAsync, but for the Azure Storage backend, this only checks the connection Azure Table Storage and not necessarily its Queue or Blob connection. Furthermore, there may be scenarios in which client's want to query information about backend-specific metadata.

I could imagine an API like the following:

public abstract class DurableTaskClient : IOrchestrationSubmitter, IAsyncDisposable
{
    public abstract Task<TaskHubInfo> GetTaskHubInfoAsync(CancellationToken cancellationToken = default);
}

public class TaskHubInfo
{
    public string Name { get; }
    public DateTimeOffset Created { get; }
    public int RunningOrchestrationCount { get; }
    public int RunningActivityCount { get; }
}

Different backends could contribute their own metadata, like the following for Azure Storage:

public class AzureStorageTaskHubInfo : TaskHubInfo
{
    public int PartitionCount { get; }
    public int WorkerQueueMessageCount { get; }
    public IReadOnlyList<int> ControlQueueMessageCounts { get; }
}

For users that know what backend they're operating with, they can leverage this additional information:

using CancellationTokenSource cts = new();
TaskHubInfo info = await _durableTaskClient.GetTaskHubInfo(cts.Token);

if (info is AzureStorageTaskHubInfo storageInfo)
{
    // Process
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions