Skip to content

Commit

Permalink
Merge pull request #106 from Doxense/refac_logging
Browse files Browse the repository at this point in the history
Removal of transaction filters and re-implementation of the logging feature
  • Loading branch information
KrzysFR authored May 14, 2020
2 parents c4740ed + 8e81edf commit f37399d
Show file tree
Hide file tree
Showing 24 changed files with 1,362 additions and 2,739 deletions.
16 changes: 16 additions & 0 deletions FoundationDB.Client/FdbDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace FoundationDB.Client
using FoundationDB.Client.Core;
using FoundationDB.Client.Native;
using FoundationDB.DependencyInjection;
using FoundationDB.Filters.Logging;

/// <summary>FoundationDB database session handle</summary>
/// <remarks>An instance of this class can be used to create any number of concurrent transactions that will read and/or write to this particular database.</remarks>
Expand Down Expand Up @@ -185,6 +186,11 @@ internal FdbTransaction CreateNewTransaction(FdbOperationContext context)
if (m_defaultTimeout != 0) trans.Timeout = m_defaultTimeout;
if (m_defaultRetryLimit != 0) trans.RetryLimit = m_defaultRetryLimit;
if (m_defaultMaxRetryDelay != 0) trans.MaxRetryDelay = m_defaultMaxRetryDelay;
if (this.DefaultLogHandler != null)
{
trans.SetLogHandler(this.DefaultLogHandler, this.DefaultLogOptions);
}

// flag as ready
trans.State = FdbTransaction.STATE_READY;
return trans;
Expand Down Expand Up @@ -233,6 +239,16 @@ internal void UnregisterTransaction(FdbTransaction transaction)
//TODO: compare removed value with the specified transaction to ensure it was the correct one?
}

public void SetDefaultLogHandler(Action<FdbTransactionLog> handler, FdbLoggingOptions options = default)
{
this.DefaultLogHandler = handler;
this.DefaultLogOptions = options;
}

private Action<FdbTransactionLog> DefaultLogHandler { get; set; }

private FdbLoggingOptions DefaultLogOptions { get; set; }

#endregion

#region Transactionals...
Expand Down
13 changes: 11 additions & 2 deletions FoundationDB.Client/FdbTransaction.Snapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace FoundationDB.Client
using System.Threading;
using System.Threading.Tasks;
using Doxense.Diagnostics.Contracts;
using FoundationDB.Filters.Logging;

/// <summary>Wraps an FDB_TRANSACTION handle</summary>
public partial class FdbTransaction
Expand Down Expand Up @@ -185,8 +186,6 @@ public Task<FdbRangeChunk> GetRangeAsync(KeySelector beginInclusive,
return m_parent.m_handler.GetRangeAsync(beginInclusive, endExclusive, limit, reverse, targetBytes, mode, read, iteration, snapshot: true, ct: m_parent.m_cancellation);
}



public FdbRangeQuery<KeyValuePair<Slice, Slice>> GetRange(KeySelector beginInclusive, KeySelector endExclusive, FdbRangeOptions? options = null)
{
return m_parent.GetRangeCore(beginInclusive, endExclusive, options, snapshot: true, kv => kv);
Expand Down Expand Up @@ -260,6 +259,16 @@ void IDisposable.Dispose()
{
// NO-OP
}


public FdbTransactionLog? Log => m_parent.Log;

public bool IsLogged() => m_parent.IsLogged();

public void StopLogging() => m_parent.StopLogging();

public void Annotate(string comment) => m_parent.Annotate(comment);

}

}
Expand Down
Loading

0 comments on commit f37399d

Please sign in to comment.