Azure / Azure/durabletask

Customizing the CreateClient/CreateRetryableClient flow

Open
#834 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.7k
Forks
335
Avg merge
2d 23h
Merged PRs (30d)
6

Description

`CreateClient`/`CreateRetryableClient` are used to create a client, that wraps invocation of methods as activities. This is achieved by creating proxies for retries (the `RetryProxy` class) and for the actual task scheduling (the `ScheduleProxy` class).

However, this flow is none-customizable - I have little control on how things gets invoked - I might want to write my own traces, send metrics, etc.

I'm looking at two possible solutions:

1. Expose a CreateClient method that accepts custom interceptors. Something along the lines of:
```cs
public virtual T CreateRetryableClient(RetryOptions retryOptions, bool useFullyQualifiedMethodNames, params IInterceptor[] additionalInterceptors) where T : class
{
if (!typeof(T).IsInterface && !typeof(T).IsClass)
{
throw new InvalidOperationException($"{nameof(T)} must be an interface or class.");
}

IInterceptor scheduleProxy = new ScheduleProxy(this, useFullyQualifiedMethodNames);
IInterceptor retryProxy = new RetryProxy(this, retryOptions);

T scheduleInstance = ProxyGenerator.CreateInterfaceProxyWithoutTarget(scheduleProxy);
T retriedInstance = ProxyGenerator.CreateInterfaceProxyWithTarget(scheduleInstance, retryProxy);
return ProxyGenerator.CreateInterfaceProxyWithTarget(retriedInstance, additionalInterceptors);
}
```
The downside being that we expose the implementation detail of `IInterceptor` to callers.
2. Expose the `RetryProxy` and `ScheduleProxy` classes as public (they are currently marked as internal) - thus allowing users to implement their own `CreateClient` method.
The downside being that this will result in duplicate code for consumers

Any suggestions? Better alternatives?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.