Class ServiceBrokerAggregator
- Namespace
- Nerdbank.JsonRpc.BrokeredServices
- Assembly
- Nerdbank.JsonRpc.dll
Queries brokers in priority order, falling through only when a service is unavailable.
public sealed class ServiceBrokerAggregator : IServiceBroker, IDisposable
- Inheritance
-
ServiceBrokerAggregator
- Implements
- Inherited Members
- Extension Methods
Remarks
Errors and cancellation propagate. The aggregate does not own its constituent brokers.
Constructors
ServiceBrokerAggregator(params IServiceBroker[])
Initializes a new instance of the ServiceBrokerAggregator class.
public ServiceBrokerAggregator(params IServiceBroker[] brokers)
Parameters
brokersIServiceBroker[]Brokers in priority order.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetCapabilitiesAsync(ServiceMoniker, CancellationToken)
Gets the capabilities of the selected registration without activating it.
public ValueTask<IReadOnlyList<string>?> GetCapabilitiesAsync(ServiceMoniker moniker, CancellationToken cancellationToken = default)
Parameters
monikerServiceMonikerThe requested service.
cancellationTokenCancellationTokenCancels lookup.
Returns
- ValueTask<IReadOnlyList<string>>
Stable capability identifiers, or null when no registration exists.
GetConnectionAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)
Acquires a channel and capabilities from the same winning registration.
public ValueTask<BrokeredServiceConnection?> GetConnectionAsync(ServiceMoniker moniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)
Parameters
monikerServiceMonikerThe requested identity.
optionsServiceActivationOptionsOptions for the activation.
cancellationTokenCancellationTokenCancels acquisition.
Returns
- ValueTask<BrokeredServiceConnection>
The caller-owned connection, or null if unavailable.
GetPipeAsync(ServiceMoniker, ServiceActivationOptions, CancellationToken)
Acquires a service's raw RPC pipe.
public ValueTask<IDuplexPipe?> GetPipeAsync(ServiceMoniker moniker, ServiceActivationOptions options = default, CancellationToken cancellationToken = default)
Parameters
monikerServiceMonikerThe requested service.
optionsServiceActivationOptionsOptions for this activation.
cancellationTokenCancellationTokenCancels this request.
Returns
- ValueTask<IDuplexPipe>
A caller-owned pipe, or null if the service is unavailable. Complete both ends when finished.
GetProxyAsync<T>(IJsonRpcDescriptor<T>, ServiceActivationOptions, CancellationToken)
Acquires a service proxy whose type is inferred from its descriptor.
public ValueTask<T?> GetProxyAsync<T>(IJsonRpcDescriptor<T> descriptor, ServiceActivationOptions options = default, CancellationToken cancellationToken = default) where T : class
Parameters
descriptorIJsonRpcDescriptor<T>The descriptor, including generated proxy support.
optionsServiceActivationOptionsOptions for this activation.
cancellationTokenCancellationTokenCancels this request.
Returns
- ValueTask<T>
A caller-owned proxy, or null if the service is unavailable.
Type Parameters
TThe service interface.
Events
AvailabilityChanged
Occurs when previously queried service availability may have changed.
public event EventHandler<BrokeredServicesChangedEventArgs>? AvailabilityChanged