Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ServiceComposer/ServiceComposer.AspNetCore/llms.txt
Use this file to discover all available pages before exploring further.
ScatterGatherOptions holds the per-endpoint configuration for a scatter/gather route: the list of gatherers to call in parallel, whether to use MVC output formatters, and an optional custom aggregator type. ScatterGatherEndpointBuilderExtensions exposes two MapScatterGather overloads — one for fully in-code configuration and one that reads endpoint definitions from IConfiguration — making it easy to manage routes in code, in appsettings.json, or in a mix of both.
ScatterGatherOptions
Class in theServiceComposer.AspNetCore namespace. Passed directly to MapScatterGather or built internally when loading from configuration.
Gatherers
Task.WhenAll; their results are passed to the aggregator in completion order. Defaults to an empty list.
One or more
IGatherer instances. Each gatherer must have a unique Key
within the list.UseOutputFormatters
true, the aggregated result is passed to an MVC ObjectResult and written through the MVC output formatter pipeline, enabling full content negotiation (JSON, XML, etc.) driven by the Accept header. Gatherers should return plain .NET objects rather than JsonNode values when output formatters are in use, so all formatters can serialize them.
MVC services must be registered (e.g., services.AddControllers()) before this option takes effect. Defaults to false.
CustomAggregator
DefaultAggregator. The type must implement IAggregator and must be registered in the service collection; setting a type that does not implement IAggregator throws InvalidOperationException immediately.
A
Type that implements IAggregator. The type must be registered in DI (e.g.,
via services.AddTransient<MyAggregator>()). null uses the default aggregator.ScatterGatherEndpointBuilderExtensions
Static class in theServiceComposer.AspNetCore namespace.
MapScatterGather (code-first overload)
GET endpoint at template. When the endpoint is hit, all gatherers in options.Gatherers are invoked concurrently, their results are passed to the aggregator, and the aggregated object is written as JSON (or via output formatters when UseOutputFormatters is true). This overload does not require AddScatterGather to have been called.
The route builder (e.g.,
WebApplication or the builder inside UseEndpoints).The ASP.NET Core route template for the endpoint (e.g.,
"api/products").The per-endpoint configuration including gatherers, formatter preference, and
optional custom aggregator.
IEndpointConventionBuilder for attaching endpoint metadata.
MapScatterGather (configuration-driven overload)
configuration, creates a ScatterGatherOptions for each one, and calls the code-first overload to register a GET endpoint per route. Requires AddScatterGather to have been called during service registration so that ScatterGatherConfiguration is available in DI.
The route builder.
The configuration section containing the array of route definitions. Pass
builder.Configuration.GetSection("ScatterGather") when the array is nested
under a "ScatterGather" key.Optional callback invoked for each route after its
ScatterGatherOptions is
built from configuration but before the endpoint is registered. The first
argument is the route template string; the second is the mutable options object.
Use this to add extra gatherers or override settings for specific routes.IReadOnlyList<IEndpointConventionBuilder> — one entry per route defined in configuration.
Basic usage
Configuration JSON shape
When using the configuration-driven overload theIConfiguration section must contain an array of route objects. Each object has the following shape:
| Field | Required | Description |
|---|---|---|
Template | Yes | ASP.NET Core route template for the GET endpoint. |
UseOutputFormatters | No | Defaults to false. Set to true to enable MVC output formatters. |
Gatherers | Yes | Array of gatherer objects. |
Gatherers[].Key | Yes | Unique key for the gatherer; also used as the named HttpClient key. |
Gatherers[].DestinationUrl | Yes (for "http" type) | Base URL of the downstream endpoint. |
Gatherers[].Type | No | Gatherer factory discriminator. Defaults to "http". Register custom types with AddGathererFactory. |
Gatherers[].IgnoreDownstreamRequestErrors | No | Defaults to false. Set true to swallow downstream errors for the "http" type. |
IConfigurationSection is passed to the factory delegate registered via ScatterGatherConfiguration.AddGathererFactory.