Skip to content

Commit

Permalink
RavenDB-21980 API documentation for Session counters
Browse files Browse the repository at this point in the history
  • Loading branch information
aviv committed Feb 18, 2024
1 parent e16b433 commit 1fe4343
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

namespace Raven.Client.Documents.Session
{
/// <summary>
/// Implements Unit of Work for accessing the RavenDB server
/// </summary>
public partial class AsyncDocumentSession
{
/// <inheritdoc cref="IAsyncDocumentSession.CountersFor(string)"/>
public IAsyncSessionDocumentCounters CountersFor(string documentId)
{
return new AsyncSessionDocumentCounters(this, documentId);
}

/// <inheritdoc cref="IAsyncDocumentSession.CountersFor(object)"/>
public IAsyncSessionDocumentCounters CountersFor(object entity)
{
return new AsyncSessionDocumentCounters(this, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Raven.Client.Documents.Session
{
/// <inheritdoc cref="IAsyncSessionDocumentCounters" />
public sealed class AsyncSessionDocumentCounters : SessionCountersBase, IAsyncSessionDocumentCounters
{
public AsyncSessionDocumentCounters(InMemoryDocumentSessionOperations session, string documentId) : base(session, documentId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

namespace Raven.Client.Documents.Session
{
/// <summary>
/// Implements Unit of Work for accessing the RavenDB server
/// </summary>
public partial class DocumentSession
{
/// <inheritdoc cref="IDocumentSession.CountersFor(string)"/>
public ISessionDocumentCounters CountersFor(string documentId)
{
return new SessionDocumentCounters(this, documentId);
}

/// <inheritdoc cref="IDocumentSession.CountersFor(object)"/>
public ISessionDocumentCounters CountersFor(object entity)
{
return new SessionDocumentCounters(this, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ namespace Raven.Client.Documents.Session
{
public partial interface IAsyncDocumentSession
{
/// <summary>
/// Advanced async session API for counter operations on a specific document
/// </summary>
/// <param name="documentId">The id of the document to operate on</param>
IAsyncSessionDocumentCounters CountersFor(string documentId);

/// <summary>
/// Advanced async session API for counter operations on a specific entity
/// </summary>
/// <param name="entity">The entity to operate on</param>
IAsyncSessionDocumentCounters CountersFor(object entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@
namespace Raven.Client.Documents.Session
{
/// <summary>
/// Advanced async counters session operations
/// Provides async client API for counter operations on a specific entity
/// </summary>
public interface IAsyncSessionDocumentCounters : ISessionDocumentCountersBase
{
/// <summary>
/// Returns all the counters for a specific document.
/// Get all counters for a specific document.
/// </summary>
///<returns>A Dictionary of counter values by counter name, containing all counters for this document</returns>
Task<Dictionary<string, long?>> GetAllAsync(CancellationToken token = default);

/// <summary>
/// Returns the counter value by counter name.
/// Get counter value by counter name.
/// </summary>
///<param name="counter">Name of the counter to get</param>
/// <returns>The counter value if exists, or Null if the counter does not exist</returns>
Task<long?> GetAsync(string counter, CancellationToken token = default);

/// <summary>
/// Returns the a dictionary of counter values by counter names
/// <param name="counters">counters names</param>
/// Get values of multiple counters of the same document
/// </summary>
/// <param name="counters">Names of the counters to get</param>
/// <returns>A dictionary of counter values by counter names</returns>
Task<Dictionary<string, long?>> GetAsync(IEnumerable<string> counters, CancellationToken token = default);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

namespace Raven.Client.Documents.Session
{
/// <summary>
/// Provides an access to DocumentSessionCounters API.
/// </summary>
public partial interface IDocumentSession
{

/// <summary>
/// Advanced session API for counter operations on a specific document
/// </summary>
/// <param name="documentId">The id of the document to operate on</param>
ISessionDocumentCounters CountersFor(string documentId);

/// <summary>
/// Advanced session API for counter operations on a specific entity
/// </summary>
/// <param name="entity">The entity to operate on</param>
ISessionDocumentCounters CountersFor(object entity);

}
Expand Down
15 changes: 6 additions & 9 deletions src/Raven.Client/Documents/Session/ISessionDocumentCounters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@
namespace Raven.Client.Documents.Session
{
/// <summary>
/// Counters advanced synchronous session operations
/// Provides synchronous client API for counter operations on a specific entity
/// </summary>
public interface ISessionDocumentCounters : ISessionDocumentCountersBase
{
/// <summary>
/// Returns all the counters for a document.
/// </summary>
/// <inheritdoc cref="IAsyncSessionDocumentCounters.GetAllAsync"/>
Dictionary<string, long?> GetAll();

/// <summary>
/// Returns the counter by the counter name.
/// </summary>
/// <inheritdoc cref="IAsyncSessionDocumentCounters.GetAsync"/>
long? Get(string counter);

/// <summary>
/// Returns the a dictionary of counter values by counter names
/// <param name="counters">counters names</param>
/// Get values of multiple counters of the same document
/// </summary>
/// <param name="counters">Names of the counters to get</param>
/// <returns>A dictionary of counter values by counter names</returns>
Dictionary<string, long?> Get(IEnumerable<string> counters);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@

namespace Raven.Client.Documents.Session
{
/// <summary>
/// Counters advanced synchronous session operations
/// </summary>
public interface ISessionDocumentCountersBase
{
/// <summary>
/// Increments by delta the value of a counter
/// <param name="counter">the counter name</param>
/// Increments the counter value by the provided delta, or by 1 if delta is not provided.
/// </summary>
/// <param name="counter">The counter to increment</param>
/// <param name="delta">The value to increment by</param>
void Increment(string counter, long delta = 1);

/// <summary>
/// Marks the specified document's counter for deletion. The counter will be deleted when
/// <see cref="IDocumentSession.SaveChanges" /> is called.
/// </summary>
/// <param name="counter">the counter name</param>
/// <param name="counter">The counter to delete</param>
void Delete(string counter);

}
Expand Down
2 changes: 2 additions & 0 deletions src/Raven.Client/Documents/Session/SessionCountersBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected SessionCountersBase(InMemoryDocumentSessionOperations session, object
Session = session;
}

/// <inheritdoc cref="ISessionDocumentCountersBase.Increment(string, long)"/>
public void Increment(string counter, long delta = 1)
{
if (string.IsNullOrWhiteSpace(counter))
Expand Down Expand Up @@ -71,6 +72,7 @@ public void Increment(string counter, long delta = 1)
}
}

/// <inheritdoc cref="ISessionDocumentCountersBase.Delete(string)"/>
public void Delete(string counter)
{
if (string.IsNullOrWhiteSpace(counter))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Raven.Client.Documents.Session
{
/// <inheritdoc />
public sealed class SessionDocumentCounters : ISessionDocumentCounters
{
private readonly AsyncSessionDocumentCounters _asyncSessionCounters;
Expand Down

0 comments on commit 1fe4343

Please sign in to comment.