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
brokerIServiceBrokerThe underlying broker.
Properties
Logger
Gets the logger used for asynchronous cleanup failures.
public ILogger<ServiceBrokerClient> Logger { get; init; }
Property Value
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
descriptorIJsonRpcDescriptor<T>The contract and proxy settings. Cache entries are keyed by descriptor instance, not value equality.
optionsServiceActivationOptionsThe activation options. These participate in the cache key.
cancellationTokenCancellationTokenCancels waiting for this rental.
Returns
- ValueTask<ServiceBrokerClient.Rental<T>>
A rental whose proxy may be null when unavailable.
Type Parameters
TThe service interface inferred from the descriptor.
Events
Invalidated
Occurs after affected cache entries are invalidated.
public event EventHandler<BrokeredServicesChangedEventArgs>? Invalidated