namespace Shared.Operations;

public interface IWorkItemActionHandler
{
    string Key { get; }
    Task ExecuteAsync(string tenantId, string actorId, Guid workItemId, CancellationToken ct);
}

public sealed class WorkItemActionRegistry(IEnumerable<IWorkItemActionHandler> handlers)
{
    private readonly IReadOnlyDictionary<string, IWorkItemActionHandler> _handlers =
        handlers.ToDictionary(x => x.Key, StringComparer.OrdinalIgnoreCase);

    public bool TryGet(string key, out IWorkItemActionHandler? handler) => _handlers.TryGetValue(key, out handler);
}
