in src/Worker.Extensions.DurableTask/FunctionsDurableClientProvider.cs [98:154]
public DurableTaskClient GetClient(Uri endpoint, string? taskHub, string? connectionName, int? maxGrpcMessageSizeInBytes)
{
this.VerifyNotDisposed();
this.sync.EnterReadLock();
taskHub ??= string.Empty;
connectionName ??= string.Empty;
ClientKey key = new(endpoint, taskHub, connectionName);
try
{
this.VerifyNotDisposed();
if (this.clients!.TryGetValue(key, out ClientHolder? holder))
{
this.logger.LogTrace("DurableTaskClient resolved from cache");
return holder.Client;
}
}
finally
{
this.sync.ExitReadLock();
}
this.sync.EnterWriteLock();
try
{
this.VerifyNotDisposed();
if (this.clients!.TryGetValue(key, out ClientHolder? holder))
{
this.logger.LogTrace("DurableTaskClient resolved from cache");
return holder.Client;
}
this.logger.LogTrace(
"DurableTaskClient cache miss, constructing for Endpoint: '{Endpoint}', TaskHub: '{TaskHub}', ConnectionName: '{ConnectionName}'",
endpoint,
taskHub,
connectionName);
GrpcChannel channel = CreateChannel(key, maxGrpcMessageSizeInBytes);
GrpcDurableTaskClientOptions options = new()
{
Channel = channel,
DataConverter = this.options.DataConverter,
EnableEntitySupport = this.options.EnableEntitySupport,
};
ILogger logger = this.loggerFactory.CreateLogger<GrpcDurableTaskClient>();
GrpcDurableTaskClient client = new(taskHub, options, logger);
holder = new(client, channel);
this.clients[key] = holder;
return client;
}
finally
{
this.sync.ExitWriteLock();
}
}