Table of Contents

Class ServiceBrokerClient

Namespace
Nerdbank.JsonRpc.BrokeredServices
Assembly
Nerdbank.JsonRpc.dll

Caches service proxies while allowing independent rentals to outlive invalidation.

public sealed class ServiceBrokerClient : IDisposable
Inheritance
ServiceBrokerClient
Implements
Inherited Members

Remarks

The client does not own its broker. Dispose each rental and then the client.

Constructors

ServiceBrokerClient(IServiceBroker)

Initializes a new instance of the ServiceBrokerClient class.

public ServiceBrokerClient(IServiceBroker broker)

Parameters

broker IServiceBroker

The underlying broker.

Properties

Logger

Gets the logger used for asynchronous cleanup failures.

public ILogger<ServiceBrokerClient> Logger { get; init; }

Property Value

ILogger<ServiceBrokerClient>

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetProxyAsync<T>(IJsonRpcDescriptor<T>, ServiceActivationOptions, CancellationToken)

Rents a cached proxy. Caller cancellation affects this rental, not other callers' activation.

public ValueTask<ServiceBrokerClient.Rental<T>> GetProxyAsync<T>(IJsonRpcDescriptor<T> descriptor, ServiceActivationOptions options = default, CancellationToken cancellationToken = default) where T : class

Parameters

descriptor IJsonRpcDescriptor<T>

The contract and proxy settings. Cache entries are keyed by descriptor instance, not value equality.

options ServiceActivationOptions

The activation options. These participate in the cache key.

cancellationToken CancellationToken

Cancels waiting for this rental.

Returns

ValueTask<ServiceBrokerClient.Rental<T>>

A rental whose proxy may be null when unavailable.

Type Parameters

T

The service interface inferred from the descriptor.

Events

Invalidated

Occurs after affected cache entries are invalidated.

public event EventHandler<BrokeredServicesChangedEventArgs>? Invalidated

Event Type

EventHandler<BrokeredServicesChangedEventArgs>