Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-idiomatic use of cancellation token parameters #99

Open
rjgotten opened this issue Sep 5, 2022 · 0 comments
Open

Non-idiomatic use of cancellation token parameters #99

rjgotten opened this issue Sep 5, 2022 · 0 comments

Comments

@rjgotten
Copy link

rjgotten commented Sep 5, 2022

The IDistributedLockFactory interface uses a non-standard approach where a CancellationToken? typed parameter is assigned null.

IRedLock CreateLock(string resource, TimeSpan expiryTime, TimeSpan waitTime, TimeSpan retryTime, CancellationToken? cancellationToken = null);

The standard approach is CancellationToken cancellationToken = default which is consistent with CancellationToken.None - i.e. a token that will never cancel. It seems that the default RedLockFactory implementation already is unncessarily implementing this logic by hand using a ?? null-coalescence operator, e.g.

cancellationToken ?? CancellationToken.None);

Having this as part of the interface will poison-pill any other implementations of the interface as well as all call sites into this non-standard, non-idiomatic approach to cancellation tokens as well.

Just don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant