Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wsugarman opened this issue Jul 27, 2024 · 0 comments
Labels
Enhancement New feature or request

Comments

@wsugarman
Copy link
Member

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants