-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47f39cc
commit 6fcf6d2
Showing
12 changed files
with
200 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Codibre.GrpcSqlProxy.Api; | ||
using Grpc.Core; | ||
|
||
namespace Codibre.GrpcSqlProxy.Client.Impl; | ||
|
||
internal class ContextInfo : IDisposable | ||
{ | ||
private readonly Action _clear; | ||
private readonly ExecutionContext? _executionContext; | ||
public bool Disposed { get; private set; } = false; | ||
public bool Transaction { get; set; } = false; | ||
public AsyncDuplexStreamingCall<SqlRequest, SqlResponse> Stream { get; } | ||
public SqlProxyClientResponseMonitor Monitor { get; } | ||
public ContextInfo( | ||
Func<AsyncDuplexStreamingCall<SqlRequest, SqlResponse>> getStream, | ||
Action clear | ||
) | ||
{ | ||
Stream = getStream(); | ||
Monitor = new(Stream); | ||
_clear = clear; | ||
_executionContext = ExecutionContext.Capture(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Monitor.Dispose(); | ||
Stream.Dispose(); | ||
Disposed = true; | ||
if (_executionContext is not null) ExecutionContext.Run(_executionContext, (_) => _clear(), null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/Codibre.GrpcSqlProxy.Client/Impl/SqlProxyClientTunnel.ContextInfo.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
namespace Codibre.GrpcSqlProxy.Client; | ||
|
||
public class SqlProxyException(string message) : Exception(message) { } | ||
public class SqlProxyException : Exception | ||
{ | ||
private readonly string? _stack; | ||
public SqlProxyException(string message) : base(message) | ||
{ | ||
_stack = null; | ||
} | ||
public SqlProxyException(Exception ex) : base(ex.Message) | ||
{ | ||
_stack = ex.StackTrace; | ||
} | ||
|
||
public override string? StackTrace => _stack ?? base.StackTrace; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.