The Scatter/Gather API in ServiceComposer provides a lightweight way to fan out a single incomingDocumentation 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.
GET request to multiple downstream services simultaneously, collect their responses, and aggregate the results into a unified JSON array. Unlike the full ViewModel Composition pipeline — which relies on event-driven handlers and a shared ViewModel object — Scatter/Gather is oriented toward read-only list endpoints where each downstream service contributes a batch of items and the gateway simply concatenates them.
The two setup calls required are:
services.AddScatterGather()— registers theScatterGatherConfigurationsingleton (and its built-inhttpgatherer factory) in the DI container.app.MapScatterGather(...)— registers one or moreGETendpoints that invoke the configured gatherers in parallel and write the aggregated result to the response.
ScatterGatherServiceCollectionExtensions
Static class in theServiceComposer.AspNetCore namespace.
AddScatterGather
ScatterGatherConfiguration instance, pre-registers the built-in "http" gatherer factory (which produces HttpGatherer instances), optionally invokes the configure callback so you can add custom gatherer factories, and registers the configuration as a singleton.
AddScatterGather must be called before MapScatterGather(IEndpointRouteBuilder, IConfiguration, ...) — the configuration-driven overload resolves ScatterGatherConfiguration from DI. The simpler MapScatterGather(string, ScatterGatherOptions) overload does not require AddScatterGather.
The application service collection.
Optional callback to register additional gatherer factories. When
null, only
the built-in "http" factory is available.IServiceCollection for chaining.
Minimal configuration-based setup
ScatterGatherConfiguration
Class in theServiceComposer.AspNetCore namespace. Holds the registry of gatherer factories used when loading route definitions from IConfiguration.
AddGathererFactory
MapScatterGather reads a gatherers array from IConfiguration, each entry’s Type field is matched (case-insensitively) against registered factories. The "http" type is pre-registered and produces HttpGatherer instances; call AddGathererFactory to support additional types.
The discriminator string that appears in the gatherer configuration entry’s
Type field. Matching is case-insensitive.Delegate invoked once at startup. Receives the gatherer’s configuration section
and the root
IServiceProvider. Do not resolve scoped services here — resolve
them inside IGatherer.Gather via HttpContext.RequestServices.IGatherer
Interface in theServiceComposer.AspNetCore namespace. All gatherers must implement this interface.
Key
ScatterGatherOptions.Gatherers list. Used in logging, telemetry span names, and as the named HttpClient key when HttpGatherer resolves its IHttpClientFactory client.
Gather
The current HTTP context. Use
context.RequestServices to resolve scoped services
and context.Request to access route values, query strings, and headers.Gatherer<T>
Abstract base class in theServiceComposer.AspNetCore namespace. Provides a strongly typed implementation of IGatherer and handles the covariant type bridging to IEnumerable<object>.
Constructor
The unique key for this gatherer. Throws
ArgumentException if null or whitespace.Abstract Gather
IEnumerable<T> to IEnumerable<object> automatically.
Custom gatherer example
IAggregator
Interface in theServiceComposer.AspNetCore namespace. Combines the results from all gatherers into a single object that is serialized as the final response.
Add
The items returned by a single gatherer’s
Gather call.