An open API service indexing awesome lists of open source software.

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.

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.