| | | 1 | | using System.Collections.Concurrent; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Models; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Holds the per-tenant activity descriptor dictionaries that back the activity registry. |
| | | 7 | | /// </summary> |
| | | 8 | | /// <remarks> |
| | | 9 | | /// <para> |
| | | 10 | | /// This model represents the value stored in the tenant-level registry dictionary described in ADR-0009's |
| | | 11 | | /// three-dictionary architecture. The outermost dictionary typically maps a tenant identifier (or a value |
| | | 12 | | /// representing tenant-agnostic scope) to an instance of <see cref="TenantRegistryData"/>. Within this class, |
| | | 13 | | /// the <see cref="ActivityDescriptors"/> and <see cref="ProvidedActivityDescriptors"/> properties form the |
| | | 14 | | /// inner dictionaries that index activity descriptors for that specific tenant or for tenant-agnostic activities. |
| | | 15 | | /// </para> |
| | | 16 | | /// <para> |
| | | 17 | | /// By encapsulating these dictionaries, the registry can manage activity descriptors per tenant while maintaining |
| | | 18 | | /// a consistent lookup and invalidation strategy across the entire system. |
| | | 19 | | /// </para> |
| | | 20 | | /// </remarks> |
| | | 21 | | public class TenantRegistryData |
| | | 22 | | { |
| | | 23 | | /// <summary> |
| | | 24 | | /// Primary index of activity descriptors for this tenant (or for tenant-agnostic scope). |
| | | 25 | | /// </summary> |
| | | 26 | | /// <remarks> |
| | | 27 | | /// The key is a composite of the activity <c>Type</c> (a logical activity type identifier) and its |
| | | 28 | | /// <c>Version</c>. This allows efficient lookup of a specific activity descriptor by type and version, |
| | | 29 | | /// which is the most common access pattern when compiling or executing workflows. |
| | | 30 | | /// </remarks> |
| | 153845 | 31 | | public ConcurrentDictionary<(string Type, int Version), ActivityDescriptor> ActivityDescriptors { get; } = new(); |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Secondary index of activity descriptors grouped by their provider type. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <remarks> |
| | | 37 | | /// This dictionary maps a provider <see cref="Type"/> (for example, an activity provider implementation) |
| | | 38 | | /// to the collection of <see cref="ActivityDescriptor"/> instances contributed by that provider for this |
| | | 39 | | /// tenant. It complements <see cref="ActivityDescriptors"/> by enabling provider-centric operations such as |
| | | 40 | | /// refreshing, removing, or re-registering all descriptors originating from a given provider. |
| | | 41 | | /// </remarks> |
| | 2357 | 42 | | public ConcurrentDictionary<Type, ICollection<ActivityDescriptor>> ProvidedActivityDescriptors { get; } = new(); |
| | | 43 | | } |