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

Provider interface for SQL locks #13

Closed
madelson opened this issue Dec 26, 2017 · 2 comments
Closed

Provider interface for SQL locks #13

madelson opened this issue Dec 26, 2017 · 2 comments
Milestone

Comments

@madelson
Copy link
Owner

When using the library with IOC patterns it's often desirable to inject connection information separately from the type of lock or lock name. A centralized provider API would simplify this:

class SqlDistributedLockProvider
{
    // factory methods
    SqlDistributedLock CreateLock(string name);
    SqlDistributedLock CreateLockWithExactName(string name); // does not use GetSafeName()
    SqlDistributedReaderWriterLock CreateReaderWriterLock(string name);
    ...

    // we may also want to offer convenience methods for locking directly
    IDisposable TryAcquireExclusiveLock(string name, TimeSpan timeout, CancellationToken cancellationToken);
}
@XtremeOwnageDotCom
Copy link

XtremeOwnageDotCom commented Dec 17, 2018

Here is my implementation of a interface, used with dependancy injection:

https://pastebin.com/jBGgVY5J

(Couldn't get the formatting working properly)

@XtremeOwnageDotCom
Copy link

I personally prefer this method- as it only requires me to reference this library in the project which contains my database connection.

The interface is defined in my "interfaces" class, which is referenced everywhere.

@madelson madelson added this to the 2.0 milestone Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants