| | | 1 | | namespace AsyncResponse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Transport-neutral description of where a remote system should publish an async response. |
| | | 5 | | /// Transport packages translate their native reply destinations (for example Pub/Sub topics or |
| | | 6 | | /// broker exchanges) into this shape so application flows can pass reply metadata without taking |
| | | 7 | | /// a dependency on a specific transport package. |
| | | 8 | | /// </summary> |
| | | 9 | | public sealed class AsyncResponseReplyTarget |
| | | 10 | | { |
| | | 11 | | /// <summary>A stable logical name for this target, such as <c>default</c> or <c>regional-us</c>.</summary> |
| | | 12 | | public required string Name { get; init; } |
| | | 13 | | |
| | | 14 | | /// <summary>The transport that owns the target, such as <c>google-pubsub</c>.</summary> |
| | | 15 | | public required string Transport { get; init; } |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// The transport-native address, such as a canonical topic, queue, exchange, or URL. |
| | | 19 | | /// Consumers that need structured values should read <see cref="Properties"/>. |
| | | 20 | | /// </summary> |
| | | 21 | | public required string Address { get; init; } |
| | | 22 | | |
| | | 23 | | /// <summary>Additional transport-specific values, for example <c>projectId</c> and <c>topicId</c>.</summary> |
| | 3 | 24 | | public Dictionary<string, string> Properties { get; init; } = new(StringComparer.Ordinal); |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Context passed to triggers that need both the generated correlation id and the selected reply |
| | | 29 | | /// target. The same values are also available ambiently through <see cref="AsyncResponseContext"/> |
| | | 30 | | /// while the trigger executes. |
| | | 31 | | /// </summary> |
| | | 32 | | public sealed record AsyncResponseRequestContext( |
| | | 33 | | string CorrelationId, |
| | | 34 | | AsyncResponseReplyTarget? ReplyTarget); |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Optional capability registered by transport packages that can provide async-response reply |
| | | 38 | | /// targets. Core uses this only when application code explicitly calls |
| | | 39 | | /// <c>WithReplyTarget(...)</c> on a waiter builder. |
| | | 40 | | /// </summary> |
| | | 41 | | public interface IAsyncResponseReplyTargetProvider |
| | | 42 | | { |
| | | 43 | | /// <summary> |
| | | 44 | | /// Resolves a reply target by logical name. Passing <c>null</c> asks for the provider's |
| | | 45 | | /// default target. |
| | | 46 | | /// </summary> |
| | | 47 | | AsyncResponseReplyTarget GetReplyTarget(string? name = null); |
| | | 48 | | } |