diff --git a/src/Proto.Actor/ActorSystem.cs b/src/Proto.Actor/ActorSystem.cs
index 129b5eb594..bcc309911c 100644
--- a/src/Proto.Actor/ActorSystem.cs
+++ b/src/Proto.Actor/ActorSystem.cs
@@ -45,32 +45,71 @@ public ActorSystem(ActorSystemConfig config)
RunThreadPoolStats();
}
+ ///
+ /// Unique Id of the actor system. Used as member id for cluster members.
+ /// This is generated by the actor system and is used to identify the actor system in the network.
+ ///
public string Id { get; } = Guid.NewGuid().ToString("N");
+ ///
+ /// Address of the actor system when used in Proto.Remote or Proto.Cluster.
+ ///
public string Address { get; private set; } = NoHost;
+ ///
+ /// Configuration used to create the actor system.
+ ///
public ActorSystemConfig Config { get; }
+ ///
+ /// Manages all processes in the actor system (actors, futures, event stream, etc.).
+ ///
public ProcessRegistry ProcessRegistry { get; }
+ ///
+ /// Root context of the actor system. Use it to spawn actors or send messages from outside of an actor context.
+ ///
public IRootContext Root { get; }
+ ///
+ /// Allows to access the stop cancellation token and stop reason.
+ /// Use to stop the actor system.
+ ///
public Stopper Stopper { get; }
+ ///
+ /// Manages all the guardians in the actor system.
+ ///
public Guardians Guardians { get; }
+ ///
+ /// DeadLetter process that receives all messages that could not be delivered to an actor.
+ ///
public DeadLetterProcess DeadLetter { get; }
+ ///
+ /// Allows to broadcast messages across the actor system to anyone who explicitly subscribed.
+ ///
public EventStream EventStream { get; }
+ ///
+ /// Diagnostics and metrics for the actor system.
+ ///
public ProtoMetrics Metrics { get; }
+ ///
+ /// Contains extensions for the actor system. Examples: Cluster, PubSub, etc.
+ ///
public ActorSystemExtensions Extensions { get; }
private Lazy DeferredFuture { get; }
internal FutureFactory Future => DeferredFuture.Value;
+ ///
+ /// Cancellation token use to stop the actor system. Register a callback for this token to be notified when the ActorSystem begins stopping.
+ /// Use to stop the actor system.
+ ///
public CancellationToken Shutdown => Stopper.Token;
private void RunThreadPoolStats()
@@ -97,6 +136,11 @@ private void RunThreadPoolStats()
);
}
+ ///
+ /// Stops the actor system and records the reason.
+ ///
+ /// Shutdown reason
+ ///
public Task ShutdownAsync(string reason="")
{
try
@@ -112,6 +156,11 @@ public Task ShutdownAsync(string reason="")
return Task.CompletedTask;
}
+ ///
+ /// Sets the network address of the actor system. Used by Proto.Remote.
+ ///
+ ///
+ ///
public void SetAddress(string host, int port)
{
_host = host;
@@ -119,6 +168,9 @@ public void SetAddress(string host, int port)
Address = $"{host}:{port}";
}
+ ///
+ /// Sets the address of the actor system to client address. Used by Proto.Remote.
+ ///
public void SetClientAddress()
{
Address = $"{Client}/{Id}";
@@ -129,12 +181,30 @@ public void SetClientAddress()
public RootContext NewRoot(MessageHeader? headers = null, params Func[] middleware) =>
new(this, headers, middleware);
+ ///
+ /// Gets the network address of the actor system. Used by Proto.Remote.
+ ///
+ ///
public (string Host, int Port) GetAddress() => (_host, _port);
+ ///
+ /// Applies props configuration delegate from actor system configuration.
+ ///
+ ///
+ ///
public Props ConfigureProps(Props props) => Config.ConfigureProps(props);
+ ///
+ /// Applies props configuration delegate for system actors.
+ ///
+ ///
+ ///
+ ///
public Props ConfigureSystemProps(string name, Props props) => Config.ConfigureSystemProps(name, props);
+ ///
+ /// Stops the actor system with reason = "Disposed"
+ ///
public async ValueTask DisposeAsync()
{
await ShutdownAsync("Disposed");
diff --git a/src/Proto.Actor/Behavior.cs b/src/Proto.Actor/Behavior.cs
index a5ab5825da..ffc5c3c076 100644
--- a/src/Proto.Actor/Behavior.cs
+++ b/src/Proto.Actor/Behavior.cs
@@ -8,26 +8,52 @@
namespace Proto;
+///
+/// Utility class for creating state machines. See Behaviors for more information.
+///
public class Behavior
{
private readonly Stack _behaviors = new();
+ ///
+ /// Initializes the behavior with an initial message handler. Use to set initial message handler.
+ ///
public Behavior()
{
}
+ ///
+ /// Initializes the behavior with an initial message handler.
+ ///
+ /// Function to process actor's messages
public Behavior(Receive receive) => Become(receive);
+ ///
+ /// Switches to a new behavior. Previous behavior stack is cleared.
+ ///
+ /// Function to process actor's messages
public void Become(Receive receive)
{
_behaviors.Clear();
_behaviors.Push(receive);
}
+ ///
+ /// Switches to a new behavior. Previous behavior is stored on a stack.
+ ///
+ ///
public void BecomeStacked(Receive receive) => _behaviors.Push(receive);
+ ///
+ /// Restores previous behavior from the stack.
+ ///
public void UnbecomeStacked() => _behaviors.Pop();
+ ///
+ /// Handle the message with currently active message handler (behavior).
+ ///
+ /// Actor context to process
+ ///
public Task ReceiveAsync(IContext context)
{
var behavior = _behaviors.Peek();
diff --git a/src/Proto.Actor/CancellationTokens.cs b/src/Proto.Actor/CancellationTokens.cs
index 0a21d5d048..70f6a33ef0 100644
--- a/src/Proto.Actor/CancellationTokens.cs
+++ b/src/Proto.Actor/CancellationTokens.cs
@@ -12,19 +12,34 @@ namespace Proto;
public static class CancellationTokens
{
private record TokenEntry(DateTimeOffset Timestamp, CancellationToken Token);
-
+
private static readonly ConcurrentDictionary Tokens = new();
+ ///
+ /// Gets a cancellation token that will be cancelled after the specified time rounded up to nearest second.
+ ///
+ /// The tokens creation is optimized and they are reused, hence cancellation timeout can be off by (at most) 500ms.
+ /// Because of that it is best to use this method when the timeout is at least several seconds
+ ///
+ ///
public static CancellationToken FromSeconds(TimeSpan duration)
{
- var seconds = (int)Math.Ceiling(duration.TotalSeconds);
+ var seconds = (int) Math.Ceiling(duration.TotalSeconds);
return FromSeconds(seconds);
}
+ ///
+ /// Gets a cancellation token that will be cancelled after specified number of seconds.
+ ///
+ ///
+ /// The tokens creation is optimized and they are reused, hence cancellation timeout can be off by (at most) 500ms.
+ /// Because of that it is best to use this method when the timeout is at least several seconds
+ ///
+ /// Thrown if seconds is less than 1
public static CancellationToken FromSeconds(int seconds)
{
if (seconds < 1) throw new ArgumentOutOfRangeException(nameof(seconds));
-
+
static TokenEntry ValueFactory(int seconds)
{
var cts = new CancellationTokenSource(seconds * 1000);
@@ -45,7 +60,14 @@ static TokenEntry ValueFactory(int seconds)
Tokens.TryRemove(seconds, out _);
}
}
- [Obsolete("Use and dispose CancellationTokenSource, or use CancellationTokens.FromSeconds",true)]
+
+ [Obsolete("Use and dispose CancellationTokenSource, or use CancellationTokens.FromSeconds", true)]
public static CancellationToken WithTimeout(int ms) => new CancellationTokenSource(ms).Token;
+
+ ///
+ /// Creates a new CancellationTokenSource that will be cancelled after the specified time.
+ ///
+ ///
+ ///
public static CancellationToken WithTimeout(TimeSpan timeSpan) => new CancellationTokenSource(timeSpan).Token;
}
\ No newline at end of file
diff --git a/src/Proto.Actor/Channels/ChannelPublisherActor.cs b/src/Proto.Actor/Channels/ChannelPublisherActor.cs
index 807288fb1b..b6f905c9ad 100644
--- a/src/Proto.Actor/Channels/ChannelPublisherActor.cs
+++ b/src/Proto.Actor/Channels/ChannelPublisherActor.cs
@@ -14,8 +14,10 @@ namespace Proto.Channels;
public static class ChannelPublisher
{
///
- /// Starts a new publisher actor
+ /// Starts a new channel publisher actor. This actor will read from the given channel
+ /// and send the received messages to the subscribers. The actor will poison itself when the channel is closed.
///
+ /// Use to subscribe
/// The parent context used to spawn the actor
/// The source channel
/// The name of the publisher actor
diff --git a/src/Proto.Actor/Channels/ChannelSubscriberActor.cs b/src/Proto.Actor/Channels/ChannelSubscriberActor.cs
index adb3f6ce82..ebb75a517f 100644
--- a/src/Proto.Actor/Channels/ChannelSubscriberActor.cs
+++ b/src/Proto.Actor/Channels/ChannelSubscriberActor.cs
@@ -13,7 +13,8 @@ namespace Proto.Channels;
public static class ChannelSubscriber
{
///
- /// Starts a new subscriber actor
+ /// Starts a new subscriber actor, that subscribes to messages from .
+ /// Received messages will be sent to the specified channel.
///
/// The parent context used to spawn
/// The PID of the publisher actor to subscribe to
diff --git a/src/Proto.Actor/Configuration/ActorSystemConfig.cs b/src/Proto.Actor/Configuration/ActorSystemConfig.cs
index 5cd87aedec..8106f5b698 100644
--- a/src/Proto.Actor/Configuration/ActorSystemConfig.cs
+++ b/src/Proto.Actor/Configuration/ActorSystemConfig.cs
@@ -16,19 +16,19 @@ namespace Proto;
public record ActorSystemConfig
{
///
- /// The interval used to trigger DeadLetter throttling
+ /// The interval used to trigger throttling of deadletter message logs
///
public TimeSpan DeadLetterThrottleInterval { get; init; }
///
- /// The counter used to trigger DeadLetter throttling
+ /// The counter used to trigger throttling of deadletter message logs
/// DeadLetter throttling triggers when there are DeadLetterThrottleCount deadletters in DeadLetterThrottleInterval
/// time
///
public int DeadLetterThrottleCount { get; init; }
///
- /// Enables logging for DeadLetter responses in Request/RequestAsync
+ /// Enables logging for DeadLetter events in Request/RequestAsync (when a message reaches DeadLetter instead of target actor)
/// When disabled, the requesting code is responsible for logging manually
///
public bool DeadLetterRequestLogging { get; set; } = true;
@@ -39,7 +39,7 @@ public record ActorSystemConfig
public bool DeveloperSupervisionLogging { get; init; }
///
- /// Enables actor metrics
+ /// Enables actor metrics. Set to true if you want to export the metrics with OpenTelemetry exporters.
///
public bool MetricsEnabled { get; init; }
@@ -59,6 +59,7 @@ public record ActorSystemConfig
///
/// Allows ActorSystem-wide augmentation of system Props
/// All system props are translated via this function
+ /// By default, DeadlineDecorator, LoggingContextDecorator are used. Additionally, the supervision strategy is set to AlwaysRestart.
///
public Func ConfigureSystemProps { get; init; } = (_,props) => {
var logger = Log.CreateLogger("Proto.SystemActors");
@@ -101,6 +102,10 @@ public record ActorSystemConfig
/// The default timeout for RequestAsync calls
///
public TimeSpan ActorRequestTimeout { get; init; } = TimeSpan.FromSeconds(5);
+
+ ///
+ /// Enables logging for DeadLetter responses in Request/RequestAsync (responses returned from DeadLetter to original sender)
+ ///
public bool DeadLetterResponseLogging { get; init; } = false;
///
@@ -109,40 +114,103 @@ public record ActorSystemConfig
/// The new ActorSystemConfig
public static ActorSystemConfig Setup() => new();
+ ///
+ /// The interval used to trigger throttling of deadletter message logs
+ ///
public ActorSystemConfig WithDeadLetterThrottleInterval(TimeSpan deadLetterThrottleInterval) =>
this with {DeadLetterThrottleInterval = deadLetterThrottleInterval};
+ ///
+ /// The counter used to trigger throttling of deadletter message logs
+ /// DeadLetter throttling triggers when there are DeadLetterThrottleCount deadletters in DeadLetterThrottleInterval
+ /// time
+ ///
public ActorSystemConfig WithDeadLetterThrottleCount(int deadLetterThrottleCount) =>
this with {DeadLetterThrottleCount = deadLetterThrottleCount};
+ ///
+ /// Enables logging for DeadLetter responses in Request/RequestAsync
+ /// When disabled, the requesting code is responsible for logging manually
+ ///
public ActorSystemConfig WithDeadLetterRequestLogging(bool enabled) => this with {DeadLetterRequestLogging = enabled};
+ ///
+ /// Enables SharedFutures
+ /// SharedFutures allows the ActorSystem to avoid registering a new temporary process for each request
+ /// Instead registering a SharedFuture that can handle multiple requests internally
+ ///
+ /// The number of requests that can be handled by a SharedFuture
public ActorSystemConfig WithSharedFutures(int size = 5000) => this with {SharedFutures = true, SharedFutureSize = size};
+ ///
+ /// Developer debugging feature, enables extended logging for actor supervision failures
+ ///
public ActorSystemConfig WithDeveloperSupervisionLogging(bool enabled) => this with {DeveloperSupervisionLogging = enabled};
-
+
+ ///
+ /// Enables actor metrics. Set to true if you want to export the metrics with OpenTelemetry exporters.
+ ///
public ActorSystemConfig WithMetrics(bool enabled = true) => this with {MetricsEnabled = enabled};
+ ///
+ /// Function used to serialize actor state to a diagnostics string
+ /// Can be used together with RemoteDiagnostics to view the state of remote actors
+ ///
public ActorSystemConfig WithDiagnosticsSerializer(Func serializer) => this with {DiagnosticsSerializer = serializer};
+ ///
+ /// Allows adding middleware to the root context exposed by the ActorSystem.
+ /// The result from this will be used as the default sender for all requests,
+ /// except requests overriding the sender context by parameter
+ ///
public ActorSystemConfig WithConfigureRootContext(Func configureContext) => this with {ConfigureRootContext = configureContext};
+
+ ///
+ /// Allows ActorSystem-wide augmentation of any Props
+ /// All props are translated via this function
+ ///
public ActorSystemConfig WithConfigureProps(Func configureProps) => this with {ConfigureProps = configureProps};
+ ///
+ /// Allows ActorSystem-wide augmentation of system Props
+ /// All system props are translated via this function
+ /// By default, DeadlineDecorator, LoggingContextDecorator are used. Additionally, the supervision strategy is set to AlwaysRestart.
+ ///
public ActorSystemConfig WithConfigureSystemProps(Func configureSystemProps) => this with {ConfigureSystemProps = configureSystemProps};
+ ///
+ /// Measures the time it takes from scheduling a Task, until the task starts to execute
+ /// If this deadline expires, the ActorSystem logs that the threadpool is running hot
+ ///
public ActorSystemConfig WithThreadPoolStatsTimeout(TimeSpan threadPoolStatsTimeout)
=> this with {ThreadPoolStatsTimeout = threadPoolStatsTimeout};
+ ///
+ /// Enables more extensive threadpool stats logging
+ ///
public ActorSystemConfig WithDeveloperThreadPoolStatsLogging(bool enabled) => this with {DeveloperThreadPoolStatsLogging = enabled};
+ ///
+ /// The default timeout for RequestAsync calls
+ ///
public ActorSystemConfig WithActorRequestTimeout(TimeSpan timeout) => this with {ActorRequestTimeout = timeout};
+ ///
+ /// Enables logging for DeadLetter responses in Request/RequestAsync (responses returned from DeadLetter to original sender)
+ ///
public ActorSystemConfig WithDeadLetterResponseLogging(bool enabled) => this with {DeadLetterResponseLogging = enabled};
}
//Not part of the contract, but still shipped out of the box
public static class ActorSystemConfigExtensions
{
+ ///
+ /// Enables logging when the Receive method on an actor takes too long. This method appends to wraps existing ConfigureProps delegate.
+ ///
+ ///
+ /// Time allowed for Receive call
+ /// Log level to use
+ ///
public static ActorSystemConfig WithDeveloperReceiveLogging(
this ActorSystemConfig self,
TimeSpan receiveDeadline,
diff --git a/src/Proto.Actor/Context/ActorContextDecorator.cs b/src/Proto.Actor/Context/ActorContextDecorator.cs
index df03005229..7ce0af1141 100644
--- a/src/Proto.Actor/Context/ActorContextDecorator.cs
+++ b/src/Proto.Actor/Context/ActorContextDecorator.cs
@@ -12,6 +12,9 @@
// ReSharper disable once CheckNamespace
namespace Proto;
+///
+/// Base class for decorators that decorate (extend) an .
+///
public abstract class ActorContextDecorator : IContext
{
private readonly IContext _context;
diff --git a/src/Proto.Actor/Context/ActorLoggingContext.cs b/src/Proto.Actor/Context/ActorLoggingContext.cs
index 94e65744b4..4e32574ad9 100644
--- a/src/Proto.Actor/Context/ActorLoggingContext.cs
+++ b/src/Proto.Actor/Context/ActorLoggingContext.cs
@@ -24,6 +24,9 @@ public static Props WithLoggingContextDecorator(
props.WithContextDecorator(ctx => new ActorLoggingContext(ctx, logger, logLevel, infrastructureLogLevel, exceptionLogLevel));
}
+///
+/// A decorator for that logs events related to message delivery to the actor.
+///
public class ActorLoggingContext : ActorContextDecorator
{
private readonly ILogger _logger;
diff --git a/src/Proto.Actor/Context/DeadlineContextDecorator.cs b/src/Proto.Actor/Context/DeadlineContextDecorator.cs
index b7893439e9..d1aba3c2d8 100644
--- a/src/Proto.Actor/Context/DeadlineContextDecorator.cs
+++ b/src/Proto.Actor/Context/DeadlineContextDecorator.cs
@@ -15,6 +15,13 @@ namespace Proto.Context;
[PublicAPI]
public static class DeadlineContextExtensions
{
+ ///
+ /// Adds a decorator for a that logs warning message if Receive takes more time than specified timeout.
+ ///
+ ///
+ /// The timeout for Receive to complete
+ ///
+ ///
public static Props WithDeadlineDecorator(
this Props props,
TimeSpan deadline,
@@ -22,6 +29,10 @@ ILogger logger
) =>
props.WithContextDecorator(ctx => new DeadlineContextDecorator(ctx, deadline, logger));
}
+
+///
+/// A decorator for a that logs warning message if Receive takes more time than specified timeout.
+///
public class DeadlineContextDecorator : ActorContextDecorator
{
private readonly TimeSpan _deadline;
diff --git a/src/Proto.Actor/Context/IContext.cs b/src/Proto.Actor/Context/IContext.cs
index a71bda00ab..7f69714ef6 100644
--- a/src/Proto.Actor/Context/IContext.cs
+++ b/src/Proto.Actor/Context/IContext.cs
@@ -11,6 +11,9 @@
// ReSharper disable once CheckNamespace
namespace Proto;
+///
+/// All contextual information available for a given actor
+///
public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, IStopperContext
{
///
@@ -19,7 +22,7 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
CancellationToken CancellationToken { get; }
///
- /// Gets the receive timeout.
+ /// Gets the receive timeout. It will be TimeSpan.Zero if receive timeout was not set
///
TimeSpan ReceiveTimeout { get; }
@@ -29,13 +32,13 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
IReadOnlyCollection Children { get; }
///
- /// Sends a response to the current Sender. If the Sender is null, the actor will panic.
+ /// Sends a response to the current Sender. If the Sender is null, this call has no effect apart from warning log entry.
///
/// The message to send
void Respond(object message);
-
+
///
- /// Sends a response to the current Sender, including message header
+ /// Sends a response to the current Sender, including message header. If the Sender is null, this call has no effect apart from warning log entry.
///
/// The message to send
///
@@ -47,7 +50,7 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
void Stash();
///
- /// Registers the actor as a watcher for the specified PID.
+ /// Registers the actor as a watcher for the specified PID. When the PID terminates the watcher is notified with message.
///
/// The PID to watch
void Watch(PID pid);
@@ -59,15 +62,22 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
void Unwatch(PID pid);
///
- /// Sets the receive timeout. If no message is received for the given duration, a ReceiveTimeout message will be sent
+ /// Sets the receive timeout. If no message is received for the given duration, a message will be sent
/// to the actor. If a message is received within the given duration, the timer is reset, unless the message implements
- /// INotInfluenceReceiveTimeout.
+ ///
///
/// The receive timeout duration
void SetReceiveTimeout(TimeSpan duration);
+ ///
+ /// Cancels the receive timeout.
+ ///
void CancelReceiveTimeout();
+ ///
+ /// Forwards the current message in the context to another actor.
+ ///
+ /// Actor to forward to
void Forward(PID target);
///
@@ -77,7 +87,7 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
/// asynchronous operation completes.
///
/// the Task to await
- /// the continuation to call once the task is completed
+ /// The continuation to call once the task is completed. The awaited task is passed in as a parameter.
/// The generic type of the task
void ReenterAfter(Task target, Func, Task> action);
@@ -87,32 +97,33 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
/// The concept is called Reentrancy, where an actor can continue to process messages while also awaiting that some
/// asynchronous operation completes.
///
- /// the Task to await
- /// the continuation to call once the task is completed
+ /// The Task to await
+ /// The continuation to call once the task is completed
void ReenterAfter(Task target, Action action);
-
+
///
/// Awaits the given target task and once completed, the given action is then completed within the actors concurrency
/// constraint.
/// The concept is called Reentrancy, where an actor can continue to process messages while also awaiting that some
/// asynchronous operation completes.
///
- /// the Task to await
- /// the continuation to call once the task is completed
+ /// The Task to await
+ /// The continuation to call once the task is completed. The awaited task is passed in as a parameter.
void ReenterAfter(Task target, Action action);
-
+
///
/// Awaits the given target task and once completed, the given action is then completed within the actors concurrency
/// constraint.
/// The concept is called Reentrancy, where an actor can continue to process messages while also awaiting that some
/// asynchronous operation completes.
///
- /// the Task to await
- /// the continuation to call once the task is completed
- void ReenterAfter(Task target, Func action);
+ /// The Task to await
+ /// The continuation to call once the task is completed. The awaited task is passed in as a parameter.
+ void ReenterAfter(Task target, Func action);
///
- /// Captures the current MessageOrEnvelope for the ActorContext
+ /// Captures the current MessageOrEnvelope for the ActorContext. Use this to stash messages for later processing. Use
+ /// to process stored messages.
///
/// The Captured Context
CapturedContext Capture();
@@ -125,7 +136,8 @@ public interface IContext : ISenderContext, IReceiverContext, ISpawnerContext, I
void Apply(CapturedContext capturedContext);
///
- /// Calls the callback on token cancellation. If CancellationToken is non-cancellable, this is a noop.
+ /// Calls the callback when specified cancellation token gets cancelled. The callback runs within actor's concurrency constrins.
+ /// If CancellationToken is non-cancellable, this is a noop.
///
/// The CancellationToken to continue after
/// The callback
diff --git a/src/Proto.Actor/Context/IContextStore.cs b/src/Proto.Actor/Context/IContextStore.cs
index b5eb2d468f..6811eef0ad 100644
--- a/src/Proto.Actor/Context/IContextStore.cs
+++ b/src/Proto.Actor/Context/IContextStore.cs
@@ -17,14 +17,14 @@ public interface IContextStore
T? Get();
///
- /// Sets a value from the actor context
+ /// Sets a value on the actor context
///
/// The value to set
/// The Type key of the value
void Set(T obj) => Set(obj);
///
- /// Sets a value from the actor context
+ /// Sets a value on the actor context
///
/// The value to set
/// The Type key of the value
diff --git a/src/Proto.Actor/Context/ISenderContext.cs b/src/Proto.Actor/Context/ISenderContext.cs
index a8df119cd4..1ced3c0d41 100644
--- a/src/Proto.Actor/Context/ISenderContext.cs
+++ b/src/Proto.Actor/Context/ISenderContext.cs
@@ -35,7 +35,7 @@ public interface ISenderContext : IInfoContext
///
/// The target PID
/// The message to send
- /// Message sender
+ /// Message sender that will receive the response
void Request(PID target, object message, PID? sender);
///
@@ -74,9 +74,9 @@ public static class SenderContextExtensions
public static BatchContext CreateBatchContext(this ISenderContext context, int size, CancellationToken ct) => new(context, size, ct);
///
- /// Sends a message together with a Sender PID, this allows the target to respond async to the Sender
+ /// Sends a message together with a Sender PID, this allows the target to respond async to the Sender.
///
- /// the context used to issue the request
+ /// The context used to issue the request. Response will be sent back to self.Self.
/// The target PID
/// The message to send
public static void Request(this ISenderContext self, PID target, object message) =>
@@ -118,7 +118,7 @@ public static async Task RequestAsync(this ISenderContext self, PID target
/// the context used to issue the request
/// The target PID
/// The message to send
- ///
+ /// Callback gets the request task passed in as a parameter
///
/// Expected return message type
public static void RequestReenter(this IContext self, PID target, object message, Func, Task> callback, CancellationToken ct)
diff --git a/src/Proto.Actor/Context/ISpawnerContext.cs b/src/Proto.Actor/Context/ISpawnerContext.cs
index fa35c55743..73fac23db8 100644
--- a/src/Proto.Actor/Context/ISpawnerContext.cs
+++ b/src/Proto.Actor/Context/ISpawnerContext.cs
@@ -12,7 +12,7 @@ namespace Proto;
public interface ISpawnerContext : ISystemContext
{
///
- /// Spawns a new child actor based on props and named using the specified name.
+ /// Spawns a new child actor based on props and specified name.
///
/// The Props used to spawn the actor
/// The actor name
diff --git a/src/Proto.Actor/Context/RootContext.cs b/src/Proto.Actor/Context/RootContext.cs
index a4cd23e99f..e4fbebb275 100644
--- a/src/Proto.Actor/Context/RootContext.cs
+++ b/src/Proto.Actor/Context/RootContext.cs
@@ -16,6 +16,12 @@ namespace Proto;
public interface IRootContext : ISpawnerContext, ISenderContext, IStopperContext
{
+ ///
+ /// Add sender middleware to the root context. Every message sent through the root context will be passed through the middleware.
+ /// The middleware will overwrite any other middleware previously added to the root context.
+ ///
+ /// Middleware to use. First entry is the outermost middleware, while last entry is innermost.
+ ///
IRootContext WithSenderMiddleware(params Func[] middleware);
}
diff --git a/src/Proto.Actor/Context/RootContextDecorator.cs b/src/Proto.Actor/Context/RootContextDecorator.cs
index 715b6deee9..186d8814ed 100644
--- a/src/Proto.Actor/Context/RootContextDecorator.cs
+++ b/src/Proto.Actor/Context/RootContextDecorator.cs
@@ -12,6 +12,9 @@
// ReSharper disable once CheckNamespace
namespace Proto;
+///
+/// A base class for decorators that decorate (extend) a .
+///
[PublicAPI]
public abstract class RootContextDecorator : IRootContext
{
diff --git a/src/Proto.Actor/Context/SystemContext.cs b/src/Proto.Actor/Context/SystemContext.cs
index b639561c83..da14eb24d8 100644
--- a/src/Proto.Actor/Context/SystemContext.cs
+++ b/src/Proto.Actor/Context/SystemContext.cs
@@ -12,6 +12,14 @@ public static class SystemContext
{
private static readonly ILogger Logger = Log.CreateLogger(nameof(SystemContext));
+ ///
+ /// Spawns a system actor with the given name.
+ ///
+ ///
+ /// Props of the actor
+ /// Name of the actor (must start with $)
+ ///
+ ///
public static PID SpawnNamedSystem(this IRootContext self, Props props, string name)
{
if (!name.StartsWith("$"))
diff --git a/src/Proto.Actor/Deduplication/DeduplicationContext.cs b/src/Proto.Actor/Deduplication/DeduplicationContext.cs
index 4b1387ba32..938f42fa55 100644
--- a/src/Proto.Actor/Deduplication/DeduplicationContext.cs
+++ b/src/Proto.Actor/Deduplication/DeduplicationContext.cs
@@ -12,8 +12,18 @@
namespace Proto.Deduplication;
+///
+/// Extracts the deduplication key from the message.
+///
+/// Type of the key
+/// The key should be returned in this variable
+/// Returns true if the key was successfully extracted, false otherwise
public delegate bool TryGetDeduplicationKey(MessageEnvelope envelope, out T? key);
+///
+/// A decorator for actor context that de-duplicates incoming messages based on the message's deduplication key.
+///
+/// Type of the deduplication key
public class DeduplicationContext : ActorContextDecorator where T : IEquatable
{
private readonly DeDuplicator _deDuplicator;
diff --git a/src/Proto.Actor/DependencyInjection/DIExtension.cs b/src/Proto.Actor/DependencyInjection/DIExtension.cs
index f070415498..68c06d1e02 100644
--- a/src/Proto.Actor/DependencyInjection/DIExtension.cs
+++ b/src/Proto.Actor/DependencyInjection/DIExtension.cs
@@ -20,6 +20,12 @@ public class DIExtension : IActorSystemExtension
[PublicAPI]
public static class Extensions
{
+ ///
+ /// Adds the DI extension to the actor system, that helps to create Props based on the DI container.
+ ///
+ ///
+ /// Service provider to use to resolve actors
+ ///
public static ActorSystem WithServiceProvider(this ActorSystem actorSystem, IServiceProvider serviceProvider)
{
var dependencyResolver = new DependencyResolver(serviceProvider);
@@ -28,6 +34,11 @@ public static ActorSystem WithServiceProvider(this ActorSystem actorSystem, ISer
return actorSystem;
}
+ ///
+ /// Access the from the DI extension. Requires that the actor system was configured with .
+ ///
+ ///
+ ///
// ReSharper disable once InconsistentNaming
public static IDependencyResolver DI(this ActorSystem system) => system.Extensions.GetRequired().Resolver;
}
\ No newline at end of file
diff --git a/src/Proto.Actor/DependencyInjection/IDependencyResolver.cs b/src/Proto.Actor/DependencyInjection/IDependencyResolver.cs
index 5b0ef8cfad..578cc39a87 100644
--- a/src/Proto.Actor/DependencyInjection/IDependencyResolver.cs
+++ b/src/Proto.Actor/DependencyInjection/IDependencyResolver.cs
@@ -7,11 +7,28 @@
namespace Proto.DependencyInjection;
+///
+/// Utility to create Props based on
+///
public interface IDependencyResolver
{
+ ///
+ /// Creates Props that resolve the actor by type, with possibility to supply additional constructor arguments
+ ///
+ /// Additional constructor arguments
+ ///
Props PropsFor(params object[] args) where TActor : IActor;
-
+
+ ///
+ /// Creates Props that resolve the actor by type
+ ///
+ ///
Props PropsFor() where TActor : IActor;
+ ///
+ /// Creates Props that resolve the actor by type
+ ///
+ ///
+ ///
Props PropsFor(Type actorType);
}
\ No newline at end of file
diff --git a/src/Proto.Actor/Diagnostics/DiagnosticTools.cs b/src/Proto.Actor/Diagnostics/DiagnosticTools.cs
index 6d4a494889..6add1ab287 100644
--- a/src/Proto.Actor/Diagnostics/DiagnosticTools.cs
+++ b/src/Proto.Actor/Diagnostics/DiagnosticTools.cs
@@ -11,6 +11,12 @@ namespace Proto.Diagnostics;
[PublicAPI]
public static class DiagnosticTools
{
+ ///
+ /// Asks an actor (or any other process) to provide diagnostics string by sending a message.
+ ///
+ ///
+ ///
+ ///
public static async Task GetDiagnosticsString(ActorSystem system, PID pid)
{
var tcs = new TaskCompletionSource();
diff --git a/src/Proto.Actor/Diagnostics/IActorDiagnostics.cs b/src/Proto.Actor/Diagnostics/IActorDiagnostics.cs
index 75ef319d23..b3697d3b20 100644
--- a/src/Proto.Actor/Diagnostics/IActorDiagnostics.cs
+++ b/src/Proto.Actor/Diagnostics/IActorDiagnostics.cs
@@ -5,7 +5,14 @@
// -----------------------------------------------------------------------
namespace Proto.Diagnostics;
+///
+/// Adds the ability to return a diagnostic string for an actor
+///
public interface IActorDiagnostics
{
+ ///
+ /// Return a diagnostic string for the actor
+ ///
+ ///
string GetDiagnosticsString();
}
\ No newline at end of file
diff --git a/src/Proto.Actor/EventStream/DeadLetter.cs b/src/Proto.Actor/EventStream/DeadLetter.cs
index 13b0eee107..2d166c8532 100644
--- a/src/Proto.Actor/EventStream/DeadLetter.cs
+++ b/src/Proto.Actor/EventStream/DeadLetter.cs
@@ -12,6 +12,11 @@
// ReSharper disable once CheckNamespace
namespace Proto;
+///
+/// A wrapper for a message that could not be delivered to the original recipient. Such message is wrapped in
+/// a by the and forwarded
+/// to the
+///
[PublicAPI]
public class DeadLetterEvent
{
@@ -27,15 +32,34 @@ public DeadLetterEvent(PID pid, object message, PID? sender, MessageHeader? head
Header = header ?? MessageHeader.Empty;
}
+ ///
+ /// The PID of the actor that was the original recipient of the message.
+ ///
public PID Pid { get; }
+
+ ///
+ /// The message that could not be delivered to the original recipient.
+ ///
public object Message { get; }
+
+ ///
+ /// Sender of the message.
+ ///
public PID? Sender { get; }
+
+ ///
+ /// Headers of the message.
+ ///
public MessageHeader Header { get; }
public override string ToString()
=> $"DeadLetterEvent: [ Pid: {Pid}, Message: {Message.GetType()}:{Message}, Sender: {Sender}, Headers: {Header} ]";
}
+///
+/// A process that receives messages, that cannot be handled by the original recipients e.g. because they have been stopped.
+/// The message is then forwarded to the as a
+///
public class DeadLetterProcess : Process
{
public DeadLetterProcess(ActorSystem system) : base(system)
diff --git a/src/Proto.Actor/EventStream/EventStream.cs b/src/Proto.Actor/EventStream/EventStream.cs
index f6c744fb98..a3c6ea8ed9 100644
--- a/src/Proto.Actor/EventStream/EventStream.cs
+++ b/src/Proto.Actor/EventStream/EventStream.cs
@@ -16,6 +16,9 @@
namespace Proto;
+///
+/// Event stream global to an actor system.
+///
[PublicAPI]
public class EventStream : EventStream