Skip to content

Commit

Permalink
RavenDB-22637 : address PR comments + add XML documentation for opera…
Browse files Browse the repository at this point in the history
…tion result objects - CountersDetail, TimeSeriesDetails and TimeSeriesRange
  • Loading branch information
aviv committed Nov 19, 2024
1 parent 3b4355b commit 0eff63b
Show file tree
Hide file tree
Showing 6 changed files with 337 additions and 18 deletions.
97 changes: 91 additions & 6 deletions src/Raven.Client/Documents/Operations/Counters/CounterBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,22 @@ namespace Raven.Client.Documents.Operations.Counters
/// </summary>
public sealed class CounterBatch
{
public bool ReplyWithAllNodesValues;
/// <summary>
/// Gets or sets a value indicating whether the response should include counter values from all nodes.
/// When set to <c>true</c>, the response includes the values of each counter from all nodes in the cluster.
/// </summary>
public bool ReplyWithAllNodesValues { get; set; }

/// <summary>
/// Gets or sets the list of counter operations to be performed on the specified documents.
/// Each <see cref="DocumentCountersOperation"/> represents a set of counter operations for a single document.
/// </summary>
public List<DocumentCountersOperation> Documents = new List<DocumentCountersOperation>();

/// <summary>
/// Gets or sets a value indicating whether the batch originated from an ETL process.
/// This is used internally to identify and manage counter operations triggered by ETL pipelines.
/// </summary>
public bool FromEtl;
}

Expand All @@ -22,8 +36,24 @@ public sealed class CounterBatch
/// </summary>
public sealed class DocumentCountersOperation
{
public List<CounterOperation> Operations;
public string DocumentId;
/// <summary>
/// Gets or sets the list of counter operations to be performed on the specified document.
/// Each operation in the list specifies an action, such as incrementing or deleting a counter.
/// </summary>
/// <remarks>
/// The <see cref="Operations"/> property is mandatory and must be populated before the batch operation is executed.
/// If it is not set or is empty, an exception will be thrown during parsing or execution.
/// </remarks>
public List<CounterOperation> Operations { get; set; }

/// <summary>
/// Gets or sets the ID of the document on which the counter operations are to be performed.
/// </summary>
/// <remarks>
/// The <see cref="DocumentId"/> property is mandatory and identifies the target document for the counter operations.
/// If it is not set, an exception will be thrown during parsing or execution.
/// </remarks>
public string DocumentId { get; set; }

public static DocumentCountersOperation Parse(BlittableJsonReaderObject input)
{
Expand Down Expand Up @@ -78,13 +108,39 @@ public DynamicJsonValue ToJson()
}
}

/// <summary>
/// Represents the types of operations that can be performed on counters in RavenDB.
/// </summary>
public enum CounterOperationType
{
/// <summary>
/// No operation. Represents the absence of any counter operation.
/// </summary>
None,

/// <summary>
/// Increases the value of the counter by a specified amount. If the counter does not exist, it will be created with the specified value.
/// </summary>
Increment,

/// <summary>
/// Deletes the counter, removing it from the database.
/// </summary>
Delete,

/// <summary>
/// Retrieves the value of a specific counter.
/// </summary>
Get,

/// <summary>
/// Used internally for sending counters by ETL
/// </summary>
Put,

/// <summary>
/// Retrieves all counters associated with a document. When using this type, 'CounterName' should not be specified.
/// </summary>
GetAll
}

Expand All @@ -93,9 +149,38 @@ public enum CounterOperationType
/// </summary>
public sealed class CounterOperation
{
public CounterOperationType Type;
public string CounterName;
public long Delta;
/// <summary>
/// Gets or sets the type of the counter operation to be performed.
/// Specifies the action, such as incrementing, deleting, or retrieving a counter value.
/// </summary>
/// <remarks>
/// Valid types are defined in the <see cref="CounterOperationType"/> enumeration, including:
/// - <see cref="CounterOperationType.Increment"/>: Increments the counter by a specified value.
/// - <see cref="CounterOperationType.Delete"/>: Deletes the counter.
/// - <see cref="CounterOperationType.Get"/>: Retrieves the value of the counter.
/// - <see cref="CounterOperationType.GetAll"/>: Retrieves all counters for a document.
/// </remarks>
public CounterOperationType Type { get; set; }

/// <summary>
/// Gets or sets the name of the counter to be operated on.
/// </summary>
/// <remarks>
/// - The <see cref="CounterName"/> property is mandatory for operations of type <see cref="CounterOperationType.Increment"/>, <see cref="CounterOperationType.Delete"/>, and <see cref="CounterOperationType.Get"/>.
/// - For <see cref="CounterOperationType.GetAll"/>, the <see cref="CounterName"/> property is not used and can be <c>null</c>.
/// - If <see cref="CounterName"/> is required but not set, an exception will be thrown during parsing or execution.
/// </remarks>
public string CounterName { get; set; }

/// <summary>
/// Gets or sets the value by which the counter should be incremented or decremented.
/// </summary>
/// <remarks>
/// - Used only for operations of type <see cref="CounterOperationType.Increment"/>.
/// - For <see cref="CounterOperationType.Put"/>, this specifies the exact value to set for the counter but is used internally and not intended for external use.
/// - For other operation types, this property is ignored.
/// </remarks>
public long Delta { get; set; }

internal string ChangeVector;
internal string DocumentId;
Expand Down
78 changes: 78 additions & 0 deletions src/Raven.Client/Documents/Operations/Counters/CountersDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@

namespace Raven.Client.Documents.Operations.Counters
{
/// <summary>
/// Represents the result of executing a <see cref="GetCountersOperation"/> or <see cref="CounterBatchOperation"/>,
/// containing details of counters associated with a document.
/// </summary>
public sealed class CountersDetail
{
/// <summary>
/// Gets or sets the list of counter details retrieved by the operation.
/// Each <see cref="CounterDetail"/> in the list provides information about a specific counter,
/// including its name and value.
/// </summary>
/// <remarks>
/// This property contains the results of either:
/// - A <see cref="GetCountersOperation"/>: Retrieves details of counters for a document.
/// - A <see cref="CounterBatchOperation"/>: Returns details of counters affected by a batch operation.
/// </remarks>
public List<CounterDetail> Counters { get; set; }

public CountersDetail()
Expand All @@ -25,14 +39,54 @@ public DynamicJsonValue ToJson()
}
}

/// <summary>
/// Represents detailed information about a counter associated with a document in RavenDB.
/// </summary>
public sealed class CounterDetail
{
/// <summary>
/// Gets or sets the ID of the document to which the counter belongs.
/// </summary>
public string DocumentId { get; set; }

/// <summary>
/// Gets or sets the name of the counter.
/// </summary>
/// <remarks>
/// This identifies the specific counter within the document.
/// </remarks>
public string CounterName { get; set; }

/// <summary>
/// Gets or sets the total value of the counter across all nodes.
/// </summary>
/// <remarks>
/// This value is the aggregate of all per-node counter values stored in <see cref="CounterValues"/>.
/// </remarks>
public long TotalValue { get; set; }

/// <summary>
/// Gets or sets the ETag associated with the counter.
/// </summary>
/// <remarks>
/// The ETag is a unique identifier used to track changes to the counter.
/// </remarks>
public long Etag { get; set; }

/// <summary>
/// Gets or sets the dictionary of counter values for each node in the cluster.
/// </summary>
/// <remarks>
/// The key is the node identifier, and the value is the counter value for that node.
/// </remarks>
public Dictionary<string, long> CounterValues { get; set; }

/// <summary>
/// Gets or sets the change vector for the counter.
/// </summary>
/// <remarks>
/// The change vector represents the version history of the counter and is used for concurrency control.
/// </remarks>
public string ChangeVector { get; set; }

internal LazyStringValue CounterKey { get; set; }
Expand All @@ -49,14 +103,38 @@ public DynamicJsonValue ToJson()
}
}

/// <summary>
/// Represents detailed information about a group of counters associated with a document in RavenDB.
/// </summary>
public sealed class CounterGroupDetail : IDisposable
{
/// <summary>
/// Gets or sets the ID of the document to which the counter group belongs.
/// </summary>
/// <remarks>
/// This property identifies the document that holds the counters in this group.
/// </remarks>
public LazyStringValue DocumentId { get; set; }

/// <summary>
/// Gets or sets the change vector for the counter group.
/// </summary>
/// <remarks>
/// The change vector represents the version history of the counter group and is used for concurrency control.
/// </remarks>
public LazyStringValue ChangeVector { get; set; }

/// <summary>
/// Gets or sets the raw Blittable JSON object containing the counter values in the group.
/// </summary>
public BlittableJsonReaderObject Values { get; set; }

/// <summary>
/// Gets or sets the ETag for the counter group.
/// </summary>
/// <remarks>
/// The ETag is a unique identifier used to track changes to the counter group.
/// </remarks>
public long Etag { get; set; }

public DynamicJsonValue ToJson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,29 @@

namespace Raven.Client.Documents.Operations.TimeSeries
{
/// <summary>
/// Represents the result of executing a <see cref="GetMultipleTimeSeriesOperation"/>,
/// providing details of time series data associated with a document in RavenDB.
/// </summary>

public sealed class TimeSeriesDetails
{
/// <summary>
/// Gets or sets the ID of the document to which the time series data belongs.
/// </summary>
/// <remarks>
/// This property identifies the document that holds the time series data retrieved by the operation.
/// </remarks>
public string Id { get; set; }

/// <summary>
/// Gets or sets a dictionary containing the time series data.
/// </summary>
/// <remarks>
/// The dictionary maps the name of each time series to a list of <see cref="TimeSeriesRangeResult"/> objects,
/// where each range result represents a segment of the time series data.
/// The data is retrieved as part of the <see cref="GetMultipleTimeSeriesOperation"/>.
/// </remarks>
public Dictionary<string, List<TimeSeriesRangeResult>> Values { get; set; }
}
}
Loading

0 comments on commit 0eff63b

Please sign in to comment.