https://github.com/shuttle/shuttle.core.transactionscope
Provides transaction scopes abstraction.
https://github.com/shuttle/shuttle.core.transactionscope
Last synced: about 1 month ago
JSON representation
Provides transaction scopes abstraction.
- Host: GitHub
- URL: https://github.com/shuttle/shuttle.core.transactionscope
- Owner: Shuttle
- License: bsd-3-clause
- Created: 2024-07-28T06:26:31.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-02-02T12:23:23.000Z (4 months ago)
- Last Synced: 2025-03-18T22:39:22.088Z (2 months ago)
- Language: C#
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shuttle.Core.TransactionScope
```
PM> Install-Package Shuttle.Core.TransactionScope
```This package makes use of the .Net `TransactionScope` class to provide ambient transaction handling.
## Configuration
The relevant components may be configured using `IServiceColletion`:
```c#
services.AddTransactionScope(builder =>
{
builder.Options.Enabled = true;
builder.Options.IsolationLevel = isolationLevel;
builder.Options.Timeout = TimeSpan.FromSeconds(30);
});
```The default JSON settings structure is as follows::
```json
{
"Shuttle": {
"TransactionScope": {
"Enabled": true,
"IsolationLevel": "isolation-level",
"Timeout": "00:00:30"
}
}
}
```# ITransactionScope
An implementation of the `ITransactionScope` interface is used to wrap a `TransactionScope`.
The `DefaultTransactionScope` makes use of the standard .NET `TransactionScope` functionality. There is also a `NullTransactionScope`, which is used when the transaction scope handling is disabled, that implements the null pattern so it implements the interface but does not do anything.
## Properties
``` c#
Guid Id { get; }
```Returns the Id of the transaction scope.
## Methods
``` c#
void Complete();
```Marks the transaction scope as complete.
# ITransactionScopeFactory
An implementation of the `ITransactionScopeFactory` interface provides instances of an `ITransactionScope` implementation.
The `TransactionScopeFactory` provides a `DefaultTransactionScope` instance if transaction scopes are `Enabled`; else a `NullTransactionScope` that implements the null pattern.
## Create
``` c#
ITransactionScope Create(IsolationLevel isolationLevel, TimeSpan timeout);
```Creates the relevant instance using the given parameters.