Skip to content

Commit 7fdad85

Browse files
committed
Enhance documentation across various interfaces
- Added XML documentation comments to IMemoryCacheClient, IJob, IQueueJob, ILockProvider, IMessagePublisher, IMessageSubscriber, Message, IQueue, IQueueActivity, IQueueEntry, ICircuitBreaker, IHaveSerializer, IFileStorage, DataDictionary, IAsyncLifetime, IHaveLogger, IHaveResiliencePolicyProvider, and IHaveTimeProvider interfaces. - Improved clarity and detail in method descriptions, parameters, and return values to facilitate better understanding and usage of the APIs.
1 parent b73bf12 commit 7fdad85

18 files changed

Lines changed: 683 additions & 29 deletions
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
namespace Foundatio.Caching;
1+
namespace Foundatio.Caching;
22

3+
/// <summary>
4+
/// Marker interface for in-memory cache implementations.
5+
/// Used to identify caches that store data in process memory rather than external stores.
6+
/// </summary>
37
public interface IMemoryCacheClient : ICacheClient
48
{
59
}

‎src/Foundatio/Jobs/IJob.cs‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using System.Threading;
44
using System.Threading.Tasks;
@@ -7,13 +7,28 @@
77

88
namespace Foundatio.Jobs;
99

10+
/// <summary>
11+
/// Represents a unit of background work that can be executed once or continuously.
12+
/// Implement this interface to create custom jobs for scheduled tasks, queue processing, or maintenance operations.
13+
/// </summary>
1014
public interface IJob
1115
{
16+
/// <summary>
17+
/// Executes the job's work.
18+
/// </summary>
19+
/// <param name="cancellationToken">Token to signal that the job should stop.</param>
20+
/// <returns>A result indicating success, failure, or cancellation.</returns>
1221
Task<JobResult> RunAsync(CancellationToken cancellationToken = default);
1322
}
1423

24+
/// <summary>
25+
/// A job that exposes configurable options for execution behavior.
26+
/// </summary>
1527
public interface IJobWithOptions : IJob
1628
{
29+
/// <summary>
30+
/// Gets or sets the options controlling job execution (name, interval, iteration limit).
31+
/// </summary>
1732
JobOptions Options { get; set; }
1833
}
1934

‎src/Foundatio/Jobs/IQueueJob.cs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@
77

88
namespace Foundatio.Jobs;
99

10+
/// <summary>
11+
/// A job that processes items from a queue. Each invocation of <see cref="IJob.RunAsync"/>
12+
/// dequeues and processes a single item.
13+
/// </summary>
14+
/// <typeparam name="T">The type of message payload in the queue.</typeparam>
1015
public interface IQueueJob<T> : IJob where T : class
1116
{
1217
/// <summary>
13-
/// Processes a queue entry and returns the result. This method is typically called from RunAsync()
14-
/// but can also be called from a function passing in the queue entry.
18+
/// Processes a single queue entry. Called by <see cref="IJob.RunAsync"/> after dequeuing an item.
19+
/// Can also be called directly when the queue entry is obtained externally.
1520
/// </summary>
21+
/// <param name="queueEntry">The queue entry to process.</param>
22+
/// <param name="cancellationToken">Token to signal that processing should stop.</param>
23+
/// <returns>A result indicating success or failure of processing.</returns>
1624
Task<JobResult> ProcessAsync(IQueueEntry<T> queueEntry, CancellationToken cancellationToken);
25+
26+
/// <summary>
27+
/// Gets the queue this job processes items from.
28+
/// </summary>
1729
IQueue<T> Queue { get; }
1830
}
1931

‎src/Foundatio/Lock/ILockProvider.cs‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,93 @@
99

1010
namespace Foundatio.Lock;
1111

12+
/// <summary>
13+
/// Provides distributed locking to coordinate access to shared resources across processes.
14+
/// </summary>
1215
public interface ILockProvider
1316
{
17+
/// <summary>
18+
/// Acquires a lock on the specified resource, waiting until available or cancellation.
19+
/// </summary>
20+
/// <param name="resource">The resource identifier to lock. Use consistent naming across processes.</param>
21+
/// <param name="timeUntilExpires">
22+
/// How long the lock is held before automatic release. Defaults to 20 minutes.
23+
/// For long-running operations, call <see cref="ILock.RenewAsync"/> periodically.
24+
/// </param>
25+
/// <param name="releaseOnDispose">If true, the lock is released when disposed.</param>
26+
/// <param name="cancellationToken">Token to cancel the acquisition attempt.</param>
27+
/// <returns>An <see cref="ILock"/> representing the acquired lock, or null if acquisition was cancelled.</returns>
1428
Task<ILock> AcquireAsync(string resource, TimeSpan? timeUntilExpires = null, bool releaseOnDispose = true, CancellationToken cancellationToken = default);
29+
30+
/// <summary>
31+
/// Checks whether a resource is currently locked.
32+
/// </summary>
33+
/// <param name="resource">The resource identifier to check.</param>
34+
/// <returns>True if the resource is locked; otherwise, false.</returns>
1535
Task<bool> IsLockedAsync(string resource);
36+
37+
/// <summary>
38+
/// Releases a specific lock on a resource.
39+
/// </summary>
40+
/// <param name="resource">The resource identifier.</param>
41+
/// <param name="lockId">The unique identifier of the lock to release.</param>
1642
Task ReleaseAsync(string resource, string lockId);
43+
44+
/// <summary>
45+
/// Releases any lock on a resource regardless of lock ID.
46+
/// Use with caution as this may release locks held by other processes.
47+
/// </summary>
48+
/// <param name="resource">The resource identifier.</param>
1749
Task ReleaseAsync(string resource);
50+
51+
/// <summary>
52+
/// Extends the expiration time of an existing lock.
53+
/// </summary>
54+
/// <param name="resource">The resource identifier.</param>
55+
/// <param name="lockId">The unique identifier of the lock to renew.</param>
56+
/// <param name="timeUntilExpires">The new expiration duration from now.</param>
1857
Task RenewAsync(string resource, string lockId, TimeSpan? timeUntilExpires = null);
1958
}
2059

60+
/// <summary>
61+
/// Represents an acquired lock on a resource. Dispose to release the lock.
62+
/// </summary>
2163
public interface ILock : IAsyncDisposable
2264
{
65+
/// <summary>
66+
/// Extends the lock expiration to prevent automatic release during long-running operations.
67+
/// </summary>
68+
/// <param name="timeUntilExpires">The new expiration duration from now.</param>
2369
Task RenewAsync(TimeSpan? timeUntilExpires = null);
70+
71+
/// <summary>
72+
/// Explicitly releases the lock, allowing other processes to acquire it.
73+
/// </summary>
2474
Task ReleaseAsync();
75+
76+
/// <summary>
77+
/// Gets the unique identifier for this lock instance.
78+
/// </summary>
2579
string LockId { get; }
80+
81+
/// <summary>
82+
/// Gets the resource identifier this lock is held on.
83+
/// </summary>
2684
string Resource { get; }
85+
86+
/// <summary>
87+
/// Gets the UTC time when this lock was acquired.
88+
/// </summary>
2789
DateTime AcquiredTimeUtc { get; }
90+
91+
/// <summary>
92+
/// Gets the duration spent waiting to acquire this lock.
93+
/// </summary>
2894
TimeSpan TimeWaitedForLock { get; }
95+
96+
/// <summary>
97+
/// Gets the number of times this lock has been renewed.
98+
/// </summary>
2999
int RenewalCount { get; }
30100
}
31101

‎src/Foundatio/Messaging/IMessagePublisher.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@
44

55
namespace Foundatio.Messaging;
66

7+
/// <summary>
8+
/// Publishes messages to all subscribers listening for the message type.
9+
/// </summary>
710
public interface IMessagePublisher
811
{
12+
/// <summary>
13+
/// Publishes a message to all subscribers of the specified type.
14+
/// </summary>
15+
/// <param name="messageType">The type used to route the message to subscribers.</param>
16+
/// <param name="message">The message payload to publish.</param>
17+
/// <param name="options">Optional settings for delivery delay, correlation ID, and custom properties.</param>
18+
/// <param name="cancellationToken">Token to cancel the publish operation.</param>
919
Task PublishAsync(Type messageType, object message, MessageOptions options = null, CancellationToken cancellationToken = default);
1020
}
1121

‎src/Foundatio/Messaging/IMessageSubscriber.cs‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
using System;
1+
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
44

55
namespace Foundatio.Messaging;
66

7+
/// <summary>
8+
/// Subscribes to messages published on the message bus.
9+
/// Handlers receive messages of the subscribed type and any derived types.
10+
/// </summary>
711
public interface IMessageSubscriber
812
{
13+
/// <summary>
14+
/// Registers a handler to receive messages of the specified type.
15+
/// The subscription remains active until the cancellation token is triggered.
16+
/// </summary>
17+
/// <typeparam name="T">The message type to subscribe to. Also receives messages of derived types.</typeparam>
18+
/// <param name="handler">
19+
/// The async function invoked for each received message.
20+
/// Exceptions thrown by the handler are logged but do not affect other subscribers.
21+
/// </param>
22+
/// <param name="cancellationToken">Token to cancel the subscription.</param>
923
Task SubscribeAsync<T>(Func<T, CancellationToken, Task> handler, CancellationToken cancellationToken = default) where T : class;
1024
}
1125

‎src/Foundatio/Messaging/Message.cs‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,60 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
44

55
namespace Foundatio.Messaging;
66

7+
/// <summary>
8+
/// Represents a message received from the message bus with metadata and raw payload.
9+
/// Subscribe to <see cref="IMessage"/> to receive all message types.
10+
/// </summary>
711
public interface IMessage
812
{
13+
/// <summary>
14+
/// Gets the unique identifier for this message instance.
15+
/// </summary>
916
string UniqueId { get; }
17+
18+
/// <summary>
19+
/// Gets the correlation identifier for distributed tracing.
20+
/// </summary>
1021
string CorrelationId { get; }
22+
23+
/// <summary>
24+
/// Gets the message type name used for routing.
25+
/// </summary>
1126
string Type { get; }
27+
28+
/// <summary>
29+
/// Gets the CLR type of the message payload, or null if the type cannot be resolved.
30+
/// </summary>
1231
Type ClrType { get; }
32+
33+
/// <summary>
34+
/// Gets the raw serialized message payload.
35+
/// </summary>
1336
byte[] Data { get; }
37+
38+
/// <summary>
39+
/// Deserializes and returns the message payload.
40+
/// </summary>
1441
object GetBody();
42+
43+
/// <summary>
44+
/// Gets custom properties attached to this message.
45+
/// </summary>
1546
IDictionary<string, string> Properties { get; }
1647
}
1748

49+
/// <summary>
50+
/// A typed message providing strongly-typed access to the message payload.
51+
/// </summary>
52+
/// <typeparam name="T">The type of message payload.</typeparam>
1853
public interface IMessage<T> : IMessage where T : class
1954
{
55+
/// <summary>
56+
/// Gets the deserialized message payload.
57+
/// </summary>
2058
T Body { get; }
2159
}
2260

0 commit comments

Comments
 (0)