Table of Contents

Class ServiceBrokerAggregator

Namespace
Microsoft.ServiceHub.Framework
Assembly
Microsoft.ServiceHub.Framework.dll

A class that aggregates one or more IServiceBroker instances into one, with various policies applied.

public static class ServiceBrokerAggregator
Inheritance
ServiceBrokerAggregator
Inherited Members

Methods

ForceMarshal(IServiceBroker)

Creates a new IServiceBroker that forces all RPC calls to be marshaled even if a service is available locally.

public static IServiceBroker ForceMarshal(IServiceBroker serviceBroker)

Parameters

serviceBroker IServiceBroker

The inner service broker.

Returns

IServiceBroker

The marshaling service broker.

Lazy(Func<ValueTask<IServiceBroker>>, JoinableTaskFactory?)

Creates an IServiceBroker that will lazily create the inner broker when it is first needed.

public static IServiceBroker Lazy(Func<ValueTask<IServiceBroker>> lazyServiceBroker, JoinableTaskFactory? joinableTaskFactory = null)

Parameters

lazyServiceBroker Func<ValueTask<IServiceBroker>>

The factory for the inner IServiceBroker.

joinableTaskFactory JoinableTaskFactory

The JoinableTaskFactory applicable to the process, if any.

Returns

IServiceBroker

The delegating service broker.

NonDisposable(IServiceBroker)

Creates a new IServiceBroker that does not implement IDisposable and forwards all requests to a given IServiceBroker.

public static IServiceBroker NonDisposable(IServiceBroker serviceBroker)

Parameters

serviceBroker IServiceBroker

The inner service broker to forward requests to.

Returns

IServiceBroker

The non-disposable wrapper.

Remarks

This is useful when an IServiceBroker that may implement IDisposable is being shared such that others may dispose of it if it is disposable, but the caller wants to retain exclusive control over the lifetime of the broker.

Parallel(IReadOnlyCollection<IServiceBroker>)

Creates a new IServiceBroker. Service requests are forwarded to a list of other IServiceBroker instances in parallel. At most one broker is allowed to respond with a service or all results are disposed and an exception is thrown.

public static IServiceBroker Parallel(IReadOnlyCollection<IServiceBroker> serviceBrokers)

Parameters

serviceBrokers IReadOnlyCollection<IServiceBroker>

A collection of service brokers aggregated into the new one. This collection is stored; not copied. The collection should not be modified while the returned broker is in use.

Returns

IServiceBroker

The aggregate service broker.

Resilient(IServiceBroker)

Creates a new IServiceBroker that returns stable proxies which reconnect when their underlying service proxy is invalidated.

public static IServiceBroker Resilient(IServiceBroker serviceBroker)

Parameters

serviceBroker IServiceBroker

The inner service broker.

Returns

IServiceBroker

The resilient service broker.

Remarks

The returned broker does not own serviceBroker. Resilient proxies must be disposed when they are no longer needed. When serviceBroker is already a resilient broker, it is returned unchanged.

Sequential(IReadOnlyList<IServiceBroker>)

Creates a new IServiceBroker. Service requests are forwarded to a list of other IServiceBroker instances one-at-a-time. The first broker to return a successful response is returned to the caller.

public static IServiceBroker Sequential(IReadOnlyList<IServiceBroker> serviceBrokers)

Parameters

serviceBrokers IReadOnlyList<IServiceBroker>

A list of service brokers aggregated into the new one. This collection is stored; not copied. The collection should not be modified while the returned broker is in use.

Returns

IServiceBroker

The aggregate service broker.